How to run a CMD command without openning a new window in Inno Setup

对着背影说爱祢 提交于 2019-11-30 20:55:31

问题


I am using Inno Setup installer to setup an installer file, that can invoke the .exe that I just installed through its scripting, and launch it right after installation, with the following command:

[Run]
Filename: "{cmd}"; Description: "{cm:LaunchProgram,3mtxmail}"; \
    Flags: nowait postinstall skipifsilent runascurrentuser; \
    Parameters: "/b /k "" ""{app}\my.exe"" -c ""{app}\default.conf"" "" "

When my.exe is operating, it doesn't need any interface, and should only listen to any traffic on a specific port, and write that traffic info to a log file.

However, when I execute the installer and launched the program, it still brings up a new console window, which I think the /b should have prevented. I expect not to see this new console window, and actually don't see anything on the screen.

From https://technet.microsoft.com/en-us/library/bb491005.aspx, the /b should be the flag that indicates not to open new windows for the command.

What is the correct syntax?


回答1:


It does not look like you need the cmd.exe for anything. Run your application directly instead:

[Run]
Filename: "{app}\my.exe"; Parameters: "-c ""{app}\default.conf""" \
    Description: "{cm:LaunchProgram,3mtxmail}"; \
    Flags: nowait postinstall skipifsilent runascurrentuser; 

Though if your application is a console application, it will open its own console. To prevent that, add runhidden flag.

You can actually use the runhidden flag to hide even the cmd.exe console window. But if you have no need for the cmd.exe, you should not use it.



来源:https://stackoverflow.com/questions/44039720/how-to-run-a-cmd-command-without-openning-a-new-window-in-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!