Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automatic shutdown of workstations

45 views
Skip to first unread message

Just Guessing

unread,
Jan 18, 2006, 12:26:14 PM1/18/06
to
I have a Windows SBS 2003 server. I have about fifty workstations - most are
Windows 2000 Pro - a handful of Windows XP and a couple of Windows 98 SE. I
would like to forcibly and automatically shut down most workstations in the
evening. User have a tendency to leave their computers on and logged in. I
think forcibly shutting down workstations left on from the server is the way
to handle this.
I know about shutdown.exe, but how would this be set up on the server?
Thanks!

Paul Williams [MVP]

unread,
Jan 18, 2006, 1:57:18 PM1/18/06
to
Here's a script I wrote some time ago to reboot several thousand boxes (for
an SMS upgarde ;-)

Just change the shutdown command so that it isn't rebooting.

List all computers, one per line, in a file called RebootPCs.txt in the same
folder as the script. Also, put SHUTDOWN.EXE in there (or mod the path to
the .EXE) and schedule to run each night with an account that has shutdown
permissions on all the PCs.

Run with CSCRIPT.

' **************************************************************
' RebootPCs.vbs
'
' read computer names from text file and reboot each computer
' sequentially using SHUTDOWN.
'
' paul williams, msresource.net, june 2004
'
' **************************************************************
Option explicit

const FOR_READING = 1
const FILE_NAME="RebootPCs.txt"

dim objOperatingSystem,objWshShell,objFso,objFileIn,objWmi
dim colOperatingSystems,arr()
dim strHost,str
dim i,oExec

i=0

set objWshShell=wscript.createObject("WScript.Shell")
set objFso=createObject("Scripting.FileSystemObject")
set objFileIn=objFso.openTextFile(FILE_NAME,FOR_READING)

if(err.number<>0)then err.clear : echo"File does not exist." :
wscript.quit(-1)
readHosts
rebootHosts

' ***********************************************
' readHosts()
'
'
' ***********************************************
Private Sub readHosts()
do while objFileIn.atEndOfLine<>true
reDim preserve arr(i)

str=objFileIn.readLine
arr(i)=str

i=i+1
loop
End Sub

' ***********************************************
' rebootHosts()
'
'
' ***********************************************
Private Sub rebootHosts()
for each strHost in arr
objWshShell.run "shutdown \\" & strHost & " -r -f -t 180"
next
End Sub

' ***********************************************
' echo(string messageToEcho)
'
' Sub routine simply echos the passed string.
' Sub used for outputting all information to the screen/ console
'
' ***********************************************
Private Sub echo(strMessage)
wscript.echo strMessage
End Sub


--
Paul Williams
Microsoft MVP - Windows Server - Directory Services
http://www.msresource.net | http://forums.msresource.net


"Just Guessing" <JustGu...@discussions.microsoft.com> wrote in message
news:B111E72C-FDFA-4E71...@microsoft.com...

0 new messages