![]() |
|
![]() |
Hide the DOS Command Window |
When invoking a custom action a Windows console window may sometimes also appear depending on the type of process being invoked.
Some external pages on this subject are:
The following code sets up a test bed which will be used as a basis for tests of individual programs mentioned below as well as demonstrating the issue:
;--- Create VBS which will be invoked via CSCRIPT (generating "DOS Window") --- <$FileMake "out\MsgBox.VBS"> <?SyntaxCheck> '--- We will run via cscript to test "DOS Window" problem --- Title = "Testing 'DOS Window'...." Text = wscript.arguments(0) & vbCRLF & vbCRLF & "Do you want me to return RC=0 for success?" Yn = MsgBox(Text, vbYesNoCancel+vbQuestion+vbDefaultButton1+vbSystemModal, Title) if Yn = vbYes then wscript.quit 0 else wscript.quit 1234 end if <$/FileMake> <$FileMake "out\FailAtEndToPreventInstall.VBS"> <?SyntaxCheck> msgbox "Abort to cause install failure (rollback)", vInformation, "TESTS COMPLETE" wscript.quit 999 'Don't want MSI to install (makes testing easier)! <$/FileMake> <$Files "out\MsgBox.VBS" DestDir="[INSTALLDIR]"> <$Files "out\FailAtEndToPreventInstall.VBS" DestDir="[INSTALLDIR]"> ;--- Generate FIRST/LAST Custom Actions ------------------------------------- #( <$ExeCa EXE=^[SystemFolder]cscript.exe^ Args=^"[INSTALLDIR]MsgBox.vbs" "Test #1 - WINDOW IN BACKGROUND"^ Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="StartServices-" Type="Rc0" > #) #( <$ExeCa EXE=^[SystemFolder]Wscript.exe^ ;;Don't want "DOS Window" (not testing) Args=^"[INSTALLDIR]FailAtEndToPreventInstall.VBS"^ Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="<-RegisterUser" Type="Rc0" ;;We will get non-zero return code > #)
Please note that the use of "CSCRIPT.EXE" was simply to demonstrate (create) the problem, to remove the window if thats what I wanted I'd have use "WSCRIPT.EXE"!
If you tried the above code the first message box comes up over a (normally black) command window. You can choose if return code 0 is returned to simulate success or failure of your custom action, some of the programs listed below do not correctly handle the return code, this doesn't matter if the invoked process is also that "lame".
I have listed all programs I have located here as some will have other switches or features which at times you might also need such as the setting of process priority. At the end of the day you will have to "suck it and see", what works in one situation may be useless in another.
Tested Methods |
start /min msgbox.exe "Some Title" "Some Message"
You would execute this via the appropriate command processor. You may see a Window quickly "flash". The full command line of the custom action for Windows NT+ might be:
#( <$ExeCa EXE=^[SystemFolder]Cmd.exe^ Args=^/c start /min cscript.exe "[INSTALLDIR]MsgBox.vbs" "Test #2 - START command"^ Condition=^<$CONDITION_INSTALL_ONLY> and VersionNT^ ;;CMD.EXE on WINNT+ Seq="StartServices-" Type="Rc0" > #)
<$Files "D:\DBAREIS\tools\cmdow.exe" DestDir="[INSTALLDIR]"> #( <$ExeCa EXE=^[INSTALLDIR]cmdow.exe^ Args=^/run /hid "[SystemFolder]cscript.exe" "[INSTALLDIR]MsgBox.vbs" "Test #3 - Cmdow.exe"^ Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="StartServices-" Type="Rc0" > #)
<$Files "D:\DBAREIS\tools\NirCmd.exe" DestDir="[INSTALLDIR]"> #( <$ExeCa EXE=^[INSTALLDIR]NirCmd.exe^ Args=^exec hide "[SystemFolder]cscript.exe" "[INSTALLDIR]MsgBox.vbs" "Test #4 - NirCmd.exe"^ Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="StartServices-" Type="Rc0" > #)
<$Files "D:\DBAREIS\tools\RunHiddenConsole.exe" DestDir="[INSTALLDIR]"> #( <$ExeCa EXE=^[INSTALLDIR]RunHiddenConsole.exe^ Args=^/w "[SystemFolder]cscript.exe" "[INSTALLDIR]MsgBox.vbs" "Test #5 - RunHiddenConsole.exe"^ ;;The "/W" means wait for process completion Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="StartServices-" Type="Rc0" > #)
The above code demonstrates a major deficiency in this program, it does not pass back the wrapped processes return code (you may not care).
<$Files "D:\DBAREIS\tools\StartX.exe" DestDir="[INSTALLDIR]"> #( <$ExeCa EXE=^[INSTALLDIR]StartX.exe^ Args=^/NoUI /ReturnError /b "DummyTitle" "\"[SystemFolder]cscript.exe\" \"[INSTALLDIR]MsgBox.vbs\" \"Test #6 - StartX.exe\""^ Condition=^<$CONDITION_INSTALL_ONLY>^ Seq="StartServices-" Type="Rc0" > #)
![]() ![]() |
| ![]() ![]() |