Need a line of code for a batch file to open another program and then close the original batch file
I am writing a series of batch files to demonstrate to my class what a computer virus can do. All I need is a SIMPLE line of code that 开发者_如何学Cwill open another file. Any help is greatly appreciated.
Is this what you're looking for?
@echo off
echo One
start notepad.exe
exit
echo Two
It will echo "One", start notepad, then exit the Command Prompt in which it's running. It won't echo "Two".
If you want to open a document (or a web page, or whatever) rather than an executable, just specify its pathname in place of "notepad.exe" and start
will do the right thing.
If you don't want to close the Command Prompt, but just want to end the execution of the batch script, do this:
@echo off
echo One
start notepad.exe
goto :eof
echo Two
That will return you to the prompt without echoing "Two".
Well here is how to open another executable but what do you mean close the original batch file?
start /d C:\Windows\System32\calc.exe
and then to exit early you could just use exit. but if you reach the end of the batch it may just close anyway.
精彩评论