New to batch files, first try actually. Trying to make a simple batch file that will open a new instance of notpad++. The batch file works and a new notpad++ window is opened, but the cmd window also stays open as well. How do I close the cmd window within the batch file after the new instance of notepad has been lauched?
#ECHO OFF
CALL cd C:\Program Files (x86)\Notepad++\
CALL notepad++.exe -multiInst
You can use start:
start notepad++
And there should be no need to use an explicit exit from the batch (which is done either via goto :eof or exit /b) as the start call returns immediately.
You can exit from command line only after quiting from notepad++.
1. If you wanna exit from cmd after quiting from notepad++, add EXIT to the end of your batch file.
2. Why don't you use shortcut instead of batch file to start notepad++?
Related
I'm making a steam bot. I have made a bat file to open the Node.js file that the code is on.
I don't want the first line in the cmd of what the bat file opened to be shown. Is there any way to do it not using the start command, because it makes it open in a Node.js terminal when I do that and I need to be in the cmd. The cmd window:
When I use the start command (that I don't want to use):
Tried to use the start command but turns out it opens it in a special window of Node.js.
Here is the batch file for now:
node bot.js
pause
It shows that in the cmd when the batch file runs:
C:\Users\*****\Desktop\Steam Bot>node bot.js
To suppress output of commands, the secret is to disable echo:
#echo off
node bot.js
pause
How do I close a particular window using a batch script?
Example: I have many existing windows open, and I open "My Computer" in Windows 7. How can I close this using a batch script?
also try to answer How to copy an .exe or any type of file which is hiiden using BATCH FILE? too!!
Maybe using SendKeys. Save the following as Closer.vbs:
set shell = createobject("wscript.shell")
rcSuccess = shell.AppActivate("title of window to activate")
if rcSuccess = 1 then shell.sendkeys "%{F4}"
Then make a batch file called CloseApp.BAT containing
REM Close some App
cscript /nologo closer.vbs
And run using:
CloseApp
This is a Batch file.
java -jar "C:\Users\Clustering.jar" > E:\distMatrix.txt
notepad E:\distMatrix.txt
notepad E:\dendrogram_output.txt
pause
I want to open both the notepad files together ....
'cause when distMatrix opens, dendrogram_output does not open until the previous one is closed!
What should I do?
Use start:
start notepad E:\distMatrix.txt
start notepad E:\dendrogram_output.txt
Note that once you have an argument with spaces in it, you need to use
start "" notepad "E:\some file with spaces.txt"
In this case that answer works, But sometimes you will need to use the "/B" parameter with "start" command to run a program in the "background" without wait to close the first.
Start /B program1.exe
Start /B program2.exe
Bye.
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 will 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.
I wrote a batch file, which has 3 .bat file running in background. I have another batch file which has 3 .bat file, which is used to stop those .bat file which ran in first batch file. All this is working fine, but after stopping those .bat files, first batch file's command window is not closing. I gave 'exit' to both the batch file which I wrote.
Please help me in this.
You could try starting the other batch files with
CMD /C
alternatively when they are supposed to close, you could try closing them by name directly from the other batch file:
taskkill /F /IM batchname.bat
Are you using
call batchfile.bat
to run the batchfiles? If not, the flow will be unexpected.
if you could convert it to .exe, with Bat-To-Exe-Converter, you could use:
tskill [program]
Like if you want to close a batch file which is converted called 'helloworld.exe':
tskill helloworld
What you also could use,
is:
tskill cmd
And do this a few times. It will close 1 commdandprompt/time.
I do a delayed close with some of my batch scripts this way:
FOR /l %%a in (30,-1,1) do (TITLE %TITLE% -- Closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL)
EXIT /B 0