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









share|improve this question
























  • 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

















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









share|improve this question
























  • 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















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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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




















  • 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


















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












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?






share|improve this answer




























    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.






    share|improve this answer




























      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






      share|improve this answer





















      • 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













      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      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

























      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?






      share|improve this answer

























        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?






        share|improve this answer























          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?






          share|improve this answer












          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?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 19 '13 at 23:17









          Karan

          48.7k1486156




          48.7k1486156
























              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.






              share|improve this answer

























                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.






                share|improve this answer























                  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.






                  share|improve this answer












                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 25 at 15:42









                  qq410219243

                  1




                  1






















                      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






                      share|improve this answer





















                      • 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

















                      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






                      share|improve this answer





















                      • 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















                      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






                      share|improve this answer












                      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







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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




















                      • 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




















                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Probability when a professor distributes a quiz and homework assignment to a class of n students.

                      Aardman Animations

                      Are they similar matrix