Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
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 Files\Mozilla Firefox\firefox.exe" , it doesn't start this application. –  onupirat Jan 19 '13 at 22:23

2 Answers 2

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

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

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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.