Can't make batch file to start a second .bat
up vote
0
down vote
favorite
I have this code
@echo off
cd c:windowsSystem32
for /f "skip=3 tokens=1" %%i in ('TASKLIST /FI "USERNAME eq %userdomain%%username%" /FI "STATUS eq running"') do (
if not "%%i"=="svchost.exe" (
if not "%%i"=="cmd.exe" (
if not "%%i"=="skype.exe" (
if not "%%i"=="origin.exe" (
if not "%%i"=="chrome.exe" (
echo.
taskkill /f /im "%%i"
echo.
)
)
)
)
)
)
pause
right, and what i want it to do, is to run %~dp0start.bat
at the end of all operations. How to do this? I tried the code bellow, but it doesn't work.
pause
goto start
:start
%~dp0start.bat
batch-file
add a comment |
up vote
0
down vote
favorite
I have this code
@echo off
cd c:windowsSystem32
for /f "skip=3 tokens=1" %%i in ('TASKLIST /FI "USERNAME eq %userdomain%%username%" /FI "STATUS eq running"') do (
if not "%%i"=="svchost.exe" (
if not "%%i"=="cmd.exe" (
if not "%%i"=="skype.exe" (
if not "%%i"=="origin.exe" (
if not "%%i"=="chrome.exe" (
echo.
taskkill /f /im "%%i"
echo.
)
)
)
)
)
)
pause
right, and what i want it to do, is to run %~dp0start.bat
at the end of all operations. How to do this? I tried the code bellow, but it doesn't work.
pause
goto start
:start
%~dp0start.bat
batch-file
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you triedcall %~dp0start.bat
?
– Karan
Jan 19 '13 at 21:17
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this code
@echo off
cd c:windowsSystem32
for /f "skip=3 tokens=1" %%i in ('TASKLIST /FI "USERNAME eq %userdomain%%username%" /FI "STATUS eq running"') do (
if not "%%i"=="svchost.exe" (
if not "%%i"=="cmd.exe" (
if not "%%i"=="skype.exe" (
if not "%%i"=="origin.exe" (
if not "%%i"=="chrome.exe" (
echo.
taskkill /f /im "%%i"
echo.
)
)
)
)
)
)
pause
right, and what i want it to do, is to run %~dp0start.bat
at the end of all operations. How to do this? I tried the code bellow, but it doesn't work.
pause
goto start
:start
%~dp0start.bat
batch-file
I have this code
@echo off
cd c:windowsSystem32
for /f "skip=3 tokens=1" %%i in ('TASKLIST /FI "USERNAME eq %userdomain%%username%" /FI "STATUS eq running"') do (
if not "%%i"=="svchost.exe" (
if not "%%i"=="cmd.exe" (
if not "%%i"=="skype.exe" (
if not "%%i"=="origin.exe" (
if not "%%i"=="chrome.exe" (
echo.
taskkill /f /im "%%i"
echo.
)
)
)
)
)
)
pause
right, and what i want it to do, is to run %~dp0start.bat
at the end of all operations. How to do this? I tried the code bellow, but it doesn't work.
pause
goto start
:start
%~dp0start.bat
batch-file
batch-file
edited Jan 2 at 20:25
Hennes
58.7k792141
58.7k792141
asked Jan 19 '13 at 21:01
onupirat
11
11
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you triedcall %~dp0start.bat
?
– Karan
Jan 19 '13 at 21:17
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23
add a comment |
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you triedcall %~dp0start.bat
?
– Karan
Jan 19 '13 at 21:17
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you tried
call %~dp0start.bat
?– Karan
Jan 19 '13 at 21:17
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you tried
call %~dp0start.bat
?– Karan
Jan 19 '13 at 21:17
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
Your description of what it is you're trying to do finally made the problem clear to me (probably why you should include as much detail as possible in the question itself).
Let's not even go into why you're doing this, and whether it's a great idea killing off processes such as dwm.exe (Desktop Window Manager), explorer.exe etc. in the first place.
Your problem is that you're running a batch file that is attempting to execute commands after you have forcibly killed off conhost.exe (Console Window Host).
Do you understand now why this is the equivalent of an unreachable code compiler error?
add a comment |
up vote
0
down vote
I’m taking a wild guess, since I used cmd.exe about a year ago...
Putting “pause” in front of the commands breaks the file, try adding another “pause” after the dpstart.bat. Since there is no stopping command at the end, it will skip everything after the last one.
add a comment |
up vote
-1
down vote
To start that file, type:
start %~dp0start.bat
If %~dp0start.bat is not in the same directory as the file you are trying to start it with,
pretend %~dp0start.bat is in C:UsersAdamfile
type:
cd "C:UsersAdamfile"
start %~dp0start.bat
hope i helped you
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Your description of what it is you're trying to do finally made the problem clear to me (probably why you should include as much detail as possible in the question itself).
Let's not even go into why you're doing this, and whether it's a great idea killing off processes such as dwm.exe (Desktop Window Manager), explorer.exe etc. in the first place.
Your problem is that you're running a batch file that is attempting to execute commands after you have forcibly killed off conhost.exe (Console Window Host).
Do you understand now why this is the equivalent of an unreachable code compiler error?
add a comment |
up vote
1
down vote
Your description of what it is you're trying to do finally made the problem clear to me (probably why you should include as much detail as possible in the question itself).
Let's not even go into why you're doing this, and whether it's a great idea killing off processes such as dwm.exe (Desktop Window Manager), explorer.exe etc. in the first place.
Your problem is that you're running a batch file that is attempting to execute commands after you have forcibly killed off conhost.exe (Console Window Host).
Do you understand now why this is the equivalent of an unreachable code compiler error?
add a comment |
up vote
1
down vote
up vote
1
down vote
Your description of what it is you're trying to do finally made the problem clear to me (probably why you should include as much detail as possible in the question itself).
Let's not even go into why you're doing this, and whether it's a great idea killing off processes such as dwm.exe (Desktop Window Manager), explorer.exe etc. in the first place.
Your problem is that you're running a batch file that is attempting to execute commands after you have forcibly killed off conhost.exe (Console Window Host).
Do you understand now why this is the equivalent of an unreachable code compiler error?
Your description of what it is you're trying to do finally made the problem clear to me (probably why you should include as much detail as possible in the question itself).
Let's not even go into why you're doing this, and whether it's a great idea killing off processes such as dwm.exe (Desktop Window Manager), explorer.exe etc. in the first place.
Your problem is that you're running a batch file that is attempting to execute commands after you have forcibly killed off conhost.exe (Console Window Host).
Do you understand now why this is the equivalent of an unreachable code compiler error?
answered Jan 19 '13 at 23:17
Karan
48.7k1486156
48.7k1486156
add a comment |
add a comment |
up vote
0
down vote
I’m taking a wild guess, since I used cmd.exe about a year ago...
Putting “pause” in front of the commands breaks the file, try adding another “pause” after the dpstart.bat. Since there is no stopping command at the end, it will skip everything after the last one.
add a comment |
up vote
0
down vote
I’m taking a wild guess, since I used cmd.exe about a year ago...
Putting “pause” in front of the commands breaks the file, try adding another “pause” after the dpstart.bat. Since there is no stopping command at the end, it will skip everything after the last one.
add a comment |
up vote
0
down vote
up vote
0
down vote
I’m taking a wild guess, since I used cmd.exe about a year ago...
Putting “pause” in front of the commands breaks the file, try adding another “pause” after the dpstart.bat. Since there is no stopping command at the end, it will skip everything after the last one.
I’m taking a wild guess, since I used cmd.exe about a year ago...
Putting “pause” in front of the commands breaks the file, try adding another “pause” after the dpstart.bat. Since there is no stopping command at the end, it will skip everything after the last one.
answered Nov 25 at 15:42
qq410219243
1
1
add a comment |
add a comment |
up vote
-1
down vote
To start that file, type:
start %~dp0start.bat
If %~dp0start.bat is not in the same directory as the file you are trying to start it with,
pretend %~dp0start.bat is in C:UsersAdamfile
type:
cd "C:UsersAdamfile"
start %~dp0start.bat
hope i helped you
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
add a comment |
up vote
-1
down vote
To start that file, type:
start %~dp0start.bat
If %~dp0start.bat is not in the same directory as the file you are trying to start it with,
pretend %~dp0start.bat is in C:UsersAdamfile
type:
cd "C:UsersAdamfile"
start %~dp0start.bat
hope i helped you
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
add a comment |
up vote
-1
down vote
up vote
-1
down vote
To start that file, type:
start %~dp0start.bat
If %~dp0start.bat is not in the same directory as the file you are trying to start it with,
pretend %~dp0start.bat is in C:UsersAdamfile
type:
cd "C:UsersAdamfile"
start %~dp0start.bat
hope i helped you
To start that file, type:
start %~dp0start.bat
If %~dp0start.bat is not in the same directory as the file you are trying to start it with,
pretend %~dp0start.bat is in C:UsersAdamfile
type:
cd "C:UsersAdamfile"
start %~dp0start.bat
hope i helped you
answered Apr 20 '13 at 2:12
dorky1
1
1
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
add a comment |
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
The problem is not how to start the second batch file, that bit's fine. The problem is how a batch file can continue running once conhost.exe has been forcibly terminated (akin to shooting yourself in the foot :)
– Karan
Apr 20 '13 at 12:23
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f538761%2fcant-make-batch-file-to-start-a-second-bat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What's the extra ` character after %~dp0start.bat? Is start.bat in the same directory as the first batch file? Have you tried
call %~dp0start.bat
?– Karan
Jan 19 '13 at 21:17
I tried, it doesn't work.
– onupirat
Jan 19 '13 at 21:25
Rather than saying, “it doesn't work”, how about telling us exactly what happens? And maybe also briefly explain what you want to happen, so we don’t all need to go spend 10 minutes researching your question just to understand it.
– Scott
Jan 19 '13 at 22:05
ok, this code is killing all user processes, what i want, after it's done with the processes to start an application, let's say Firefox. And when i add the line "C:Program FilesMozilla Firefoxfirefox.exe" , it doesn't start this application.
– onupirat
Jan 19 '13 at 22:23