RE: Automating tasks
- From: The Lazy Slug <TheLazySlug@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 6 May 2006 03:26:01 -0700
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
- Follow-Ups:
- RE: Automating tasks
- From: hijack
- RE: Automating tasks
- Prev by Date: Question about fax service
- Next by Date: Re: Change Password
- Previous by thread: Question about fax service
- Next by thread: RE: Automating tasks
- Index(es):
Relevant Pages
|