Re: Remote Shutdown Batch Issue

From: Richard C. (richard_at_ccommconsulting.com)
Date: 11/13/04


Date: Sat, 13 Nov 2004 18:44:08 -0500


"Dave Leonardi" <Cyberaccount72@yahoo.com> wrote in message
news:e752EKdyEHA.2516@TK2MSFTNGP10.phx.gbl...
> Good Afternoon,
>
> I had a question dealing with automating a remote shutdown for my 200
> end-users. The problem is that they are leaving their workstations on
> after
> hours(or Longer) and SUS patches and updates are not getting to them in
> the
> morning. I initially wanted to have a scheduled task run on my server
> which
> called on a batch to shut down all the remote workstations in the list I
> created. The problem is I don't know how to properly code the batch so it
> calls on a list.txt of computers. I was offered advice to use JSINC.com
> Tip
> 4195, but the solution there offers to shut down all computers in my
> domain.
> I need to be able to modify the list so I can shut down only relevant
> computers, not all of them. I was looking around for DOS commands, but am
> unable to find an effective answer. I was also contemplating running
> scheduled tasks, but I am running W2K and XP Workstations. I guess it
> would
> be easier to centralize the shutdown process on one server, batch file
> containing < Shutdown -m \\remotecomputer -s> as opposed to dealing with
> two
> task scheduler utilities and no shutdown.exe on Windows 2000. I'd
> appreciate
> it if someone could give me a hand with this problem it has become quite
> frustrating. I ultimately just want to automate the task of shutting down
> selected workstations for my domain. I am running W3K/W2K Servers and W2K,
> XP Pro workstations. Thank you again.
>
> Regards,
> Dave Leonardi
>

Here's what I do on my home LAN to force my kids off their computers after
hours. Its run as a scheduled task at midnight. Basically it loops through
an array of computer names and shuts them down. Also if there is an error
of some sort it writes an event into the App event log of sorts.

'==============================================
Dim Wsh
Set Wsh = CreateObject("Wscript.Shell")
Dim WshX
'One option is to create an array like this
Dim aComputers(4)
aComputers(0) = "PC1"
aComputers(1) = "PC2"
aComputers(2) = "PC3"
aComputers(3) = "PC4"
'Another option is to create an array using the Array() function
'Dim aComputers
'aComputers = Array("PC1","PC2","PC3")
Dim sJob
Dim i
For i = 0 To UBound(aComputers,1)
  If aComputers(i) <> "" Then
    'You can modify the shutdown options as you need
    sJob = "shutdown -m \\" & aComputers(i) & " -s -f -t 300 -c " &_
            " ""Your logon hours have expired. " & vbCrLf &_
            " You have 5 minutes before shutdown..."" "
    Set WshX = Wsh.Exec(sJob)
    Do While WshX.Status = 0
      Wscript.Sleep 10
    Loop
    Dim msg
    msg = WshX.StdOut.ReadAll & vbCrLf & WshX.StdErr.ReadAll
    If WshX.ExitCode <> 0 Then
      Wsh.LogEvent 1,msg
    End If
  End If
Next

'=============================================

Now you did mention SUS is a part of this picture. What are your Autoupdate
policies? Are you using GPO's to enforce the settings? When are patches
scheduled to install?
Perhaps all you really need to do is just adjust your policies?

FYI, we have a mix of 1,000 PCs that can either be on or off after hours so
we decided that the policy for Autoupdates is set to install patches at 4pm
and to give the users the option to reboot if the patches require it. This
allows the user to finish off what they are doing and to shut down as they
would normally or to postpone a shutdown if they need to leave their PC on
overnight to finish running some task that the computer needs to do. It has
taken some 'user education' about rebooting their PC after patches have run
and at their earliest convenience.

At another place of work (much smaller < 50 PCs) the users were trained to
leave their PCs on at night and the Autoupdate policy was set to install
patches at 3am and reboot if needed.

This was the least inconvenient for them.

My main point being that 'user education' is an important part of any patch
management strategy.

HTH

Richard C...



Relevant Pages

  • Re: Script: Remote shutdown of all domain computers
    ... If the computers are Windows ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... Because i can't realy script in VB, i am unable to create my own scripts. ... Public Function AllComputersAs String() ...
    (microsoft.public.windows.server.scripting)
  • Re: Annoying Problem - Subscript out of range
    ... only occurs on two computers, which I have limited access to. ... fname was still defined when I checked it during debugging and I never ... Dim OpenFilename As Variant ... Dim fname, officename As String ...
    (microsoft.public.excel.programming)
  • Send mail from excel - Copy/paste unformatted values and error
    ... Thanks so much, Brice ... When they try on their computers they receive an script error message. ... Dim fso As Object ... Set rng = Nothing ...
    (microsoft.public.excel.programming)
  • RE: Finetuning: Remote Shutdown with WMI, some errors occur.
    ... Also we would like that a workstation that's locked is also shutdown by this ... script to shutdown all approx. ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... Const OpenAsDefault = -2 ...
    (microsoft.public.windows.server.scripting)
  • Re: BackgroundWorker thread locking UI
    ... Protected Overrides Sub OnLoad ... tsStatus.Text = "Loading Computers. ... Private Sub bgLoadComputers_DoWork(ByVal sender As System.Object, ... Dim dtComputers As New DataTable ...
    (microsoft.public.dotnet.languages.vb)