Dant.A
Dant.A

Reputation: 197

How to run cmd.exe hidden in Inno Setup

I was wondering if there was any way to run the command prompt from Inno Setup's Exec function in a way which would hide the output from the user. Currently I have the below function which I'd like to do this for.

Exec(
    'cmd.exe',
    '/c ' + InstallPath + '\initdb ' + '-U postgres -A password -E utf8 --pwfile=' +
        InstallPath + '\password.txt -D ' + DataPath,
    '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

I know you can add a flag to the Run section, but haven't really found anything analogous to that. Any help would be appreciated.

Upvotes: 4

Views: 8597

Answers (1)

mirtheil
mirtheil

Reputation: 9192

You should be able to change the SW_SHOW to SW_HIDE to hide the command window.

For example:

Exec(
    'cmd.exe',
    '/c ' + InstallPath + '\initdb ' + '-U postgres -A password -E utf8 --pwfile=' +
        InstallPath + '\password.txt -D ' + DataPath,
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode);

For those using [Run] section, see How to run a CMD command without openning a new window in Inno Setup.

Upvotes: 7

Related Questions