I've been trying for hours to execute the following Inno Script code.
Exec('C:\Windows\System32\inetsrv\appcmd.exe', 'list site > "c:\test\temp.txt"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
It executes the appcmd program whose output is saved in a file.
The above code doesn't stream the output into a file when run from Inno Script. When I run the code from command line, it works fine. I can also execute the other commands like ipconfig
and redirect the output to the file.
I've also tried the following code but to no avail.
Exec('cmd.exe', '"/c "C:\Windows\System32\inetsrv\appcmd.exe" list site > "c:\test\temp.txt"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
I can run other commands like add site
or add apppool
. I can see that the cmd window opens but since opening and closing is almost instantaneous, I can't check the output on the window.
The return value of Exec
is True
.
I'm not exactly sure what is going wrong as I am not getting any error while executing the code.