RE: Auto shutdown of workstations



Tell you the truth I'm not sure as I never tried it, but my gut feeling is
no. Althou your could change the line strComputer = oTS.ReadLine to:

strComputer = "AULAP8-" & oTS.ReadLine

That way you would only need pc1, pc2 etc in the text file. I myself would
prefer to have the whole computer name in the text file...

Stewy

"Djmc26" wrote:

> Hi Stewy
>
> would it be possible to use in the texty file the * wildcard?
> Like for example
>
> AULAP8-*.*
>
> since all my pc are AULAP8-pc1, pc2, pc3, blah blah blah
> Thanks
> i.
>
>
> "Stewy" wrote:
>
> > I created a script at my last job that shutdown certain computers at a
> > specific time. The script would read a text file (which contained computer
> > names) and go along and shut them down. At the end it would email a log file
> > to you stating which computers where left on. The script must be fired by
> > having the argument "scheduled" otherwise it won't run. When testing we
> > accidently shut down all the computers during work hours. As for time wise we
> > set it up as a Scheduled task for a certain time. It was safer doing it this
> > way.
> >
> > This script is as is and you may need to modify it for your needs...
> >
> > '=====================================================
> > ' VBScript Source File -- Created with XLnow OnScript
> > '
> > ' AUTHOR: Stewart Brown
> > ' DATE: 17/06/2005
> > ' COMMENT: This reads a textfile of computers and shuts them down.
> > ' If anything is left open and unsaved then tough, it will be
> > ' forced to shutdown.
> > ' This has now been dumbed down for Win 2000 and below...
> > '=====================================================
> >
> > ' Before we start lets check to see if we should be running this script
> > if WScript.arguments.length > 0 then
> > Select Case WScript.arguments.item(0)
> > Case "scheduled"
> > ' We do nothing as we are suppose to run this script.
> > Case Else
> > WScript.Echo "By you running this script you are now in the process of
> > shutting down all computers across the network. Have a nice day :)"
> > WScript.Echo "Only kidding, this script has been stopped because you ran
> > it incorrectly."
> > WScript.Quit
> > End Select
> > else
> > WScript.Echo "By you running this script you are now in the process of
> > shutting down all computers across the network. Have a nice day :)"
> > WScript.Echo "Only kidding, this script has been stopped because you ran it
> > incorrectly."
> > WScript.Quit
> >
> > end if
> >
> > ' Lets force our error trapping
> > On Error Resume Next
> >
> > ' Declare Variables time
> > Dim oFSO, oTS, strComputer, colPings
> > Dim sUser, sPassword
> > Dim objEmail, strAttachmentFile, objFSO, objTextFile
> >
> > ' Lets set remote credentials
> > sUser = "## Need Admin Username ##"
> > sPassword = "## Need Admin Password ##"
> >
> > ' Settings for the email
> > Set objEmail = CreateObject("CDO.Message")
> > objEmail.From = "## Insert From email address ##"
> > objEmail.To = "## Insert To email address ##"
> > objEmail.CC = "## Insert CC email address if required. If not then comment
> > this line out ##"
> > objEmail.Subject = "Shutdown Report for " & date() & "."
> >
> > ' Set the log file
> > strAttachmentFile = "## Log file to save results
> > c:\misc\remoteshutdown\ShutDownLog.txt ##"
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > Set objTextFile = objFSO.CreateTextFile (strAttachmentFile, true)
> > objTextFile.Writeline ("Start time: " & time())
> >
> > ' Open list of client names
> > Set oFSO = CreateObject("Scripting.FileSystemObject")
> > Set oTS = oFSO.OpenTextFile("## Clients text file listing computer names
> > c:\misc\remoteshutdown\clients.txt##")
> >
> > ' Lets create our loop to read each line of the text file
> > Do Until oTS.AtEndOfStream
> >
> > ' Lets get the next client name
> > strComputer = oTS.ReadLine
> >
> > ' Lets ping
> > Set objShell = CreateObject("WScript.Shell")
> > Set objScriptExec = objShell.Exec( "ping -n 2 -w 1000 " & strComputer)
> > strPingResults = LCase(objScriptExec.StdOut.ReadAll)
> >
> > ' Lets work out the results
> > If InStr(strPingResults, "reply from") Then
> > ' Lets connect to the computer
> > Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
> > Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer,
> > "root\cimv2", sUser, sPassword)
> > If err.number <> 0 then
> > ' For testing purposes uncomment the line below
> > ' Wscript.Echo strComputer & " has confused the script or won't allow
> > remote connections"
> > objTextFile.Writeline (strComputer & " has confused the script or won't
> > allow remote connections.")
> > End if
> > ' Lets issue a shutdown to windows
> > ' 4 = force logoff
> > ' 5 = force shutdown
> > ' 6 = force reboot
> > ' 12 = force power off
> >
> > Set oWindows = objSWbemServices.ExecQuery("Select " & "Name From
> > Win32_OperatingSystem")
> > For Each oSys In oWindows
> > oSys.Win32ShutDown(5)
> > Next
> >
> > objTextFile.Writeline (strComputer & " HAS BEEN TURNED OFF.")
> > ' For testing purposes uncomment the line below
> > ' Wscript.Echo strComputer & " Computer responded and now turned off."
> > else
> > ' For testing purposes uncomment the line below
> > ' WScript.Echo strComputer & " Computer did not respond."
> > objTextFile.Writeline (strComputer & " is already off.")
> > End If
> >
> > ' Lets get our new computer name
> > Loop
> >
> > ' Lets close the text file
> > oTS.Close
> > objTextFile.Writeline ("Finish time: " & time())
> > objTextFile.Close
> >
> > ' Lets send the email
> > objEmail.AddAttachment(strAttachmentFile)
> > objEmail.Configuration.Fields.Item
> > ("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2
> > objEmail.Configuration.Fields.Item
> > ("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "## Insert
> > SMTP address ##"
> > objEmail.Configuration.Fields.Item
> > ("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25
> > objEmail.Configuration.Fields.Update
> > objEmail.Send
> >
> >
> > ' =====================================================
> >
> > In the text file with the computers names would something like;
> > M0001
> > M0002
> > M0003...
> > etc etc
> >
> > Have Fun...
> >
> > Stewy
> >
> >
> >
> > "Just Guessing" wrote:
> >
> > > 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!
> > >
.



Relevant Pages

  • Re: Retrieve information of a remote machine in vbscript
    ... It's possible to retrieve information like Operating System ... a remote machine into a domain and put this information in Access tables ... I have catched the examples in the Script Center and in Hey, ... administrator on the remote computers (Domain Admins is a member of the ...
    (microsoft.public.scripting.vbscript)
  • Re: Finding users in local admin groups
    ... > Here is a vbscript that you can run against a remote computer that moves ... > *local* users except 'Administrator) from the Administrators group to the ... You should also add to the script logging to a file of the ... > you moved on what computers. ...
    (microsoft.public.win2000.security)
  • Re: Change local administrator password ? through GPO or push script ?
    ... I would like to change the local administrator password of every computers member of my AD domain but I am not sure of the best method. ... Create a vbs script that points to the local computer and then deploy this script by GPO. ... This attribute will permit to know wich admin password is configured for this machine. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Not so Newbie
    ... The script is designed for situations like yours. ... wit 35+ computers and to go to each of those computers to individualy ... Prompt for an executable to run on each remote computer in the group. ... so you know where the deployment failed. ...
    (microsoft.public.windows.server.scripting)
  • Re: VBscript that restart the domain comptuer
    ... If you have a shutdown script that cleans up the profiles, ... permissions can restart all computers in a list remotely. ... I have already VB script I ...
    (microsoft.public.windows.server.active_directory)