If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
Can I control a program using a batch file once its been started? No. A batch file can only execute or start another program. Once it is started, it cannot perform additional functions within that program.
1] Hidden Start or HStartDrag, and drop the batch file onto the interface. Choose options including hiding console windows, UAC, and so on. You can also test it using test mode. You can also add command-line options if needed.
Use the start command to prevent the batch file from waiting for the program. Just remember to put a empty double quote in front of the program you want to run after "Start". For example, if you want to run Visual Studio 2012 from a batch command:
Start "" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
notice the double quote after start.
You can use the exit keyword. Here is an example from one of my batch files:
start myProgram.exe param1
exit
Look at the START command, you can do this:
START rest-of-your-program-name
For instance, this batch-file will wait until notepad exits:
@echo off
notepad c:\test.txt
However, this won't:
@echo off
start notepad c:\test.txt
From my own question:
start /b myProgram.exe params...
works if you start the program from an existing DOS session.
If not, call a vb script
wscript.exe invis.vbs myProgram.exe %*
The Windows Script Host Run() method takes:
Here is invis.vbs:
set args = WScript.Arguments
num = args.Count
if num = 0 then
WScript.Echo "Usage: [CScript | WScript] invis.vbs aScript.bat <some script arguments>"
WScript.Quit 1
end if
sargs = ""
if num > 1 then
sargs = " "
for k = 1 to num - 1
anArg = args.Item(k)
sargs = sargs & anArg & " "
next
end if
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With