0

I have this code

@echo off
cd c:\windows\System32
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
4
  • 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, 2013 at 21:17
  • I tried, it doesn't work.
    – onupirat
    Jan 19, 2013 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. Jan 19, 2013 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 Files\Mozilla Firefox\firefox.exe" , it doesn't start this application.
    – onupirat
    Jan 19, 2013 at 22:23

3 Answers 3

1

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?

0

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.

-1

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:\Users\Adam\file\

type:

cd "C:\Users\Adam\file\"

start %~dp0start.bat

hope i helped you

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, 2013 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .