sanjuro8998
sanjuro8998

Reputation: 1261

Shutdown in BAT - Windows 7

I have this .bat file here which kills everything and then shutdown the computer. The problem is that this shutdown command is not working ... amd I doing something wrong? I'm killing everything before shutting down because this way the shutdown is faster, thanks!

@echo off
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"=="explorer.exe" (
            if not "%%i"=="cmd.exe" (
                if not "%%i"=="tasklist.exe" (
                    echo.
                    Taskkill /f /im "%%i" 
                    echo.
                )
            )
        )
    )
)

shutdown /s /f /t 00

Upvotes: 2

Views: 851

Answers (1)

sanjuro8998
sanjuro8998

Reputation: 1261

Found the problem ... really idiot of my part, but I named the bat file as shutdown.bat ... so instead of actually shutting down the computer, it was calling itself again and again, that's why I got the loop problem :)

Upvotes: 3

Related Questions