batch to restart pc using TASKKILL and SHUTDOWN

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ralfs_k
Posts: 6
Joined: 24 Feb 2012 04:17

batch to restart pc using TASKKILL and SHUTDOWN

#1 Post by ralfs_k » 04 Mar 2012 11:15

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch to restart pc using TASKKILL and SHUTDOWN

#2 Post by foxidrive » 04 Mar 2012 11:24

Is this any quicker?

Control + Alt + Delete then Alt + U, U

ralfs_k
Posts: 6
Joined: 24 Feb 2012 04:17

Re: batch to restart pc using TASKKILL and SHUTDOWN

#3 Post by ralfs_k » 04 Mar 2012 11:52

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch to restart pc using TASKKILL and SHUTDOWN

#4 Post by foxidrive » 04 Mar 2012 12:28

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?

Post Reply