RE: Automating tasks

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Morning Jack

There a couple of ways you could do this.

1. Setup 'Scheduled Tasks' on your workstations to run the maintenance
programs that you want to and just 'wake them up' before the tasks are due to
run. This obviously will still leave you with the problem of how to shut them
down when they have finished.

2. Use the Remote WMI in a VB Script. This example can be run on your server
(or PC) and will run the built-in Disk Defragmentation program on the PC
'WORKSTATION-01'. It checks every 5 minutes whether the defragmentation has
completed and then shuts the PC down. You can obviously change it from
'defrag.exe' to 'ntbackup.exe' or any other program that you can run from a
command line. You may be able to integrate your WOL program into the script
aswell. If not, have a look at
http://www.codearchive.com/rate.php?rid=1386&go=1017 for how to do this (I
haven't personally tried this bit)

Regards
Slug

<START OF CODE>
'ShutDown Codes (Add 4 to to code to force the option)
'0 Log Off
'1 Shutdown
'2 Reboot
'8 Power Off

On Error Resume Next

iShutDown = 12

Set oOSs =
GetObject("winmgmts:{impersonationLevel=impersonate}!//WORKSTATION-01").Get("Win32_Process")

If Err.Number Then
MsgBox "Failed to find workstation"
Else
iErrProcess = oOSs.Create("defrag c: -f", "C:\WINDOWS\System32\", Null,
iProcessId)
If iErrProcess <> 0 Then
MsgBox "Defrag.exe command Failed"
Else
Do
bStillRunning = False
Set oProcesses =
GetObject("winmgmts:{impersonationLevel=impersonate}!//WORKSTATION-01").InstancesOf("Win32_Process")
For Each oProcess In oProcesses
If "defrag.exe" = oProcess.Name Then bStillRunning = True
Next
If bStillRunning Then
WScript.Sleep(50000)
Else
Set oOSs =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}//WORKSTATION-01").ExecQuery("Select * from Win32_OperatingSystem")
For Each oOS In oOSs
Err.Number = 0
oOS.Win32Shutdown (iShutDown)
If Err.Number Then
MsgBox "Shutdown Failed"
Else
MsgBox "Shutdown Executed"
End If
Exit Do
Next
End If
Loop
End If
End If
<END OF CODE>


"hijack" wrote:

I manage SBS2003 and would like to perform automatic maintenance (run virus
scans, backup, etc) on my client PCs when users are absent. The client PCs
can be started automatically (using the magic packet) but the clients cannot
be logged on for their tasks. Is there an automated method for this?
Secondly, would the sc.exe command benefit me in this situation?
Lastly how do I determine when the tasks have completed so that the client
PCs can be turned off ?

--
Thanks for the help
Jack
.



Relevant Pages

  • RE: Automating tasks
    ... 'ShutDown Codes ... MsgBox "Defrag.exe command Failed" ... For Each oProcess In oProcesses ... scans, backup, etc) on my client PCs when users are absent. ...
    (microsoft.public.windows.server.sbs)
  • Re: Workstations are going offline! Help!
    ... The Service Control Manager tried to take a corrective action (Restart the ... Then if you have WSUS, you could go to the WSUS console and see what it's ... or maybe those client PCs are not getting the appropriate gpo's ... Event logs on the workstations all say that they are unable to run group ...
    (microsoft.public.windows.server.sbs)
  • Re: Shuting down all client users(WinXP) with just one action in SBS2000.
    ... Exchange to finish a clean shutdown either. ... Of course your ability to shutdown the remote workstations depends ... is an APC UPS) is to install the mangement card in the smart slot ... You could manage it via the Powerchute Server ...
    (microsoft.public.windows.server.sbs)
  • Re: Shuting down all client users(WinXP) with just one action in SBS2000.
    ... Of course your ability to shutdown the remote workstations depends ... the UPS and then run the the Powerchute Agent on each workstation. ... You could manage it via the Powerchute Server Mangement Console. ...
    (microsoft.public.windows.server.sbs)
  • Re: Shuting down all client users(WinXP) with just one action in SBS2000.
    ... Of course your ability to shutdown the remote workstations depends ... the UPS and then run the the Powerchute Agent on each workstation. ...
    (microsoft.public.windows.server.sbs)