Page 1 of 1

batch to restart pc using TASKKILL and SHUTDOWN

Posted: 04 Mar 2012 11:15
by ralfs_k
hi i need to restart pc realy fast using batch any ides?

i tried this

Code: Select all

taskkill /F /FI "USERNAME eq testuser"
shutdown /f /r -t 00


but shutdown doesn't work after all tasks are killed any ides? I tried also:
taskkill /F /FI "USERNAME eq testuser" /IF "IMAGENAME ne cmd.exe" and taskkill /F /FI "USERNAME eq testuser" /IF "IMAGENAME ne kill.bat" but without success =[ maybe other ideas how to restart pc?

Re: batch to restart pc using TASKKILL and SHUTDOWN

Posted: 04 Mar 2012 11:24
by foxidrive
Is this any quicker?

Control + Alt + Delete then Alt + U, U

Re: batch to restart pc using TASKKILL and SHUTDOWN

Posted: 04 Mar 2012 11:52
by ralfs_k
not sure on what os you use it but in windows 7 alt+u does nothing for me...


anyway is there a way to kill all processes but not batch itself?
assigned title to batch file using TITLE KILLALL then

Code: Select all

taskkill /F /FI "USERNAME eq testuser" /FI "WINDOWTITLE ne KILLALL" /FI "IMAGENAME ne cmd.exe" /FI "IMAGENAME ne kill.bat"
but batch is killed anyway...

Re: batch to restart pc using TASKKILL and SHUTDOWN

Posted: 04 Mar 2012 12:28
by foxidrive
My OS is XP. I see Win7 has removed the functionality.

You would be best to iterate through the list of running tasks and shut down everything except cmd.exe


Are any of the tasks running open files that can be corrupted by forcefully killing the tasks?