Sunday, March 13, 2011

Bat file for reboot PC remotely

Sometimes you need reboot pc at night. It help you.

@echo off 
dsquery computer ou=workstations,dc=contoso,dc=com -o rdn > pc_workstations.txt
for /F "tokens=*" %%i in (pc_workstations.txt) do call :reboot %%i%
goto Ready

:Reboot
set remotepc=%1%
set remotepc=%remotepc:~1,-1%
shutdown /f /r /c "Reboot by administrator" /m \\%remotepc%
goto :EOF

:Ready

 

No comments: