doudun2565 2018-12-01 06:04
浏览 249

在Golang中运行带有选项的exe

I have an .exe installer, let's say installer.exe On command line, I can run the following command:

installer /quiet OPT=XY  

It runs successfully and uses those options.

Now, I want to run the same thing using GoLang code

To just run the installer, the following works:

cmd := exec.Command("CryptovisorClient")  

However, I want to run the entire command with the options - installer /quiet OPT=XY

How do I achieve this in the Go code?

  • 写回答

1条回答 默认 最新

  • doufen1933 2018-12-01 06:09
    关注

    Take a look at exec.Command's docs. It shows that the args can be passed in as a variadic. Therefore you should be able to do:

    cmd := exec.Command("installer", "/quiet", "OPT=XY")
    

    Now, I don't do much windows (and it looks like those are windows style flags), but I believe that will work.

    评论

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。