Well, I had a script that would log off all of the computers in an OU. But, what if you just wanted to log off or reboot one computer?!? Oops... I didn't think of that! Well, I guess I can't say that any more. This script will allow you to reboot, logoff or shutdown any computer.
----------COPY EVERYTHING BELOW THIS LINE----------
'This script will logoff, shutdown or reboot a computer. 'Created by Cheyenne Harden October 2 2006
On Error Resume Next
'remotely reboot a computer
Dim sUser,sPassword, sClient, sShutdown Dim oFSO, oLocator, oConnection, oWindows, oSys
'set remote credentials sUser = inputbox("Enter Login") sPassword = inputbox("Enter password") sClient = inputbox("Enter Name of Computer") sShutdown = inputbox("issue shutdown to OS" & vbCrLf & "4 = force logoff" & _ vbCrLf & "5 = force shutdown" & _ vbCrLf & "6 = force rebooot" & _ vbCrLf & "12 = force power off")
'open list of client names Set oFSO = CreateObject("Scripting.FileSystemObject") 'get WMI locator Set oLocator = CreateObject("WbemScripting.SWbemLocator")
'Connect to remote WMI Set oConnection = oLocator.ConnectServer(sClient, _ "root\cimv2", sUser, sPassword)
Set oWindows = oConnection.ExecQuery("Select " & _ "Name From Win32_OperatingSystem") For Each oSys In oWindows oSys.Win32ShutDown(sShutdown) Next
WScript.Echo "Task Completed!"
----------COPY EVERYTHING ABOVE THIS LINE----------
PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!
To make this script work you will need three things!
1. You will need an admin login. 2. You will need an admin password. 3. Lastly, you will need the name or IP of the target computer.
This information is provided "AS IS" with no warranties expressed or implied.
Advertisements
|