Monday, January 24, 2011

Shutdown Multiple PCs

To remotely run commands on a PC, you can use the PsTools "psexec" . You can donwload the pstools
from the Microsoft website. Also you need to have administrative access on the remote PC.
                             psexec \\PCToManage cmdToRun

Example: If I want to stop the spooler service on COMP1 from COMP2:
On COMP2, I type: “psexec \\COMP1 net stop spooler”

If you want to execute a command on multiple PCs, you write the names of these PCs in a textfile.txt then:
                     psexec @textfile.txt cmdToRun

Example:
If you want to try to shutdown a PC remotely you have to use “psexec @TESTSHUT.txt shutdown”
where TESTSHUT.txt is a text file that contains in each line the name of the PCs that you would like to
shutdown. An example of TESTSHUT.txt is
PC1
PC2
PC3
If you want to restart use the –r option.
If the remote computers are locked, or have running application, you must use the –f option


Ifyou want to include this in a vbscript, you have to use the run method - to run the Command prompt -
in a WshShell Object


Option Explicit
Dim objShell
set objShell = CreateObject("WScript.Shell")
objShell.run "%comspec% /k psexec @TESTSHUT.txt shutdown -r -f"
WScript.quit


If you are interested in finding a job in Information Technology or in any field. 
Post an ad in this website http://www.find1job.com/postad/employee/postadv.html

And if you are looking to hire somebody, you can also post an ad
 http://www.find1job.com/postad/employer/postadve.html
The website is completely free.

I hope my blog was helpful and I would like to thank you for reading 

No comments:

Post a Comment