How can I hide the command prompt window when launching a .BAT file?
The solution requires 2 batch files and a vb script.
1. In launch.bat (this files runs your program silently) enter...
wscript.exe "C:\path\invis.vbs" "myfile.bat"
2. In invis.vbs enter..
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
3. In myfile.bat enter whatever you need. Example:
4. Next you need to execute launch.bat from the .MSI installation.To execute a .BAT file in a Windows Installer installation, you will have to use a custom action. Do the following:
- In the .WSI file, select View > MSI Script..
- In the Installation Sequence list, click the location in the sequence where you want to place the custom action.
- Double-click the Execute Program from Path custom action on the Custom tab. The Execute Program from Path dialog displays.
- Populate the Details tab as follows:
- Name: Enter a name for the custom action.
- Property: Enter %COMSPEC. This is the environment variable that holds the location of the cmd.exe program.
- Command Line: Enter "/c <path to .BAT>\<batchfile.BAT>" (replacing the text in <> with the path and name of your batch file. Enclose the path and batch file name in double quotes. The /c switch closes the cmd.exe window after the batch file executes. To execute the batch file and keep the cmd.exe window open, enter /k instead. (This can be useful for debugging batch files.)
Note: The cmd.exe launches in the System directory by default. If your batch file executes actions in another directory, you must explicitly account for that in the batch file. For example, to list the files in c:\mydir, add a line to the batch file that reads 'cd c:\mydir'.
- Click OK.
Imported Document Id