Archive: Hidden ExecShell Program


Hidden ExecShell Program
Ive got an old skool DOS command line program that I need to execute during the install. Im currently using ExecShell but windows brings up a big ugly DOS window while it runs. The program takes a while to run and many of my users who have never seen a DOS prompt before actually close the window with unfortunate results.

I found out about SW_SHOWMINIMIZED but prefrably Id like a way to hide it entirely (maybe a SW_HIDDEN option). We used to use an installer that did this but NSIS is superior in ever other way. Anyone know of a solution?


Another problem I came across when doing something similar was in Win95/98 the DOS window didn't automatically close after the program had completed. I solved this by extracting a .pif file next to the program which was configured to make the window close automatically after running, if anyone knows of a neater way of doing this I too would appreciate it :)


These might be helpful (or not)

START /Dworkingdir /MIN /WAIT commandstring
CMD /C commandstring


The best solution would be writing a small DLL that does the same as MakeNSISw only without the log. If you wish it to log into your NSIS log window you will have to process the output for line breaks and insert it item by item to the NSIS log.


Thanks for the replies. I had a look at the "start" command, but in its current state it only seems to be able to minimise the window. A quick search on google groups show people with the same problem as me. Apparently start.exe is quite capable of hidding windows (it just has to send a different parameter to one function) but theres no switch for it.

Google groups thread

They even patched the exe to do it. But I dont really want to patch other peoples exes or have to include a version in my installer.

I also found a program called runh that hides windows. Im gonna use that for now but it'd be much neater to have it part of nsis.

Im not much of a windows coder but looking at the makensisw source it looks like you can do it pretty much with the following lines of code


GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
CreateProcess(NULL,g_script,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);

(where g_script has the path to the exe in it)

Would it be possible to include something like that into nsis?

Ooh yeah, I can't believe I forgot about that.

I had the same problem, and I wrote 2 separate tiny apps:
RunHidden - executes a given command line and hides the window
Hide - looks for a specified window and hides it

The second one is useful for programs that spawn shells on their own (would you believe Microsoft does that too?!). I Exec the program, and then hide that program's specific shell windows.

But this gets nasty if I want to use ExecWait - then I still have to use Exec, and run a loop within the script that does the hiding every 10 milliseconds or so while the program is running (so then I need to detect when the program finished as well...).

Anyway, I too will really like to see an optional /HIDE switch for Exec and ExecWait that uses SW_HIDE.


Add a feature request to the tracker at the SF site. I look at that list when deciding what to work on next.


nsExec.dll is now in cvs. It allows you to execute command-line based programs and it captures the output (with-out a dos box). This plugin should be available in the next release or you can download in from cvs at sourceforge.


Sorry to bump old topic but IMHO it's still relevant question.
Now SW_HIDE parameter is availble for ExecShell , but I have to use ExecWait and can't use this... What shall I do ? I looked throgh help file , but found nothing ...:(
BTW,in Inno it looks as

[Run]
;Filename: "{app}\cyrfonts.bat"; StatusMsg: "bla-bla"; Flags: runhidden
What's the analogue ?

For DOS application use program files\nsis\contrib\nsExec or http://forums.winamp.com/showthread....hreadid=181442 plug-in.
For Win apps it is possible to get process handle from ShellExecuteEx and use WaitForSingelObject to wait for process exit, but this require System plug-in usage experience. You can search in the archive http://nsis.sourceforge.net/archive/browse.php for script samples.


2Takhir
OK, I replied in your topic. It's a pitty , but your plugin doesn't help:(