Hello,
I need to create a couple scheduled tasks on +515 W2K DCs that are located in
many different time zones. I can create the tasks this way:
'(Using hard coded time)
'********************************************************
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
ShutdownJobCreated = objNewJob.Create ("Notepad.exe",_
& "********180000.000000-300", False , , , , JobID)
'********************************************************
I cannot create the task this way:
'********************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colTimeZone = objWMIService.ExecQuery ("Select * from Win32_TimeZone")
For Each objTimeZone In colTimeZone
If objTimeZone.DayLightBias = 0 Then
If objTimeZone.Bias >= 0 Then
objTZoffsetMinutes = "+" & objTimeZone.Bias
Elseif objTimeZone.Bias < 0 Then
objTZoffsetMinutes = objTimeZone.Bias
End If
Else
If objTimeZone.Bias = 0 Then
objTZoffsetMinutes = "+" & (objTimeZone.Bias)
Elseif objTimeZone.Bias >0 Then
objTZoffsetMinutes = "+" & (objTimeZone.Bias - 60)
Elseif objTimeZone.Bias < 0 Then
objTZoffsetMinutes = (objTimeZone.Bias + 60)
End If
End If
Next
Set objWMIService = GetObject("winmgmts:" _ &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objShutdownJob = objWMIService.Get("Win32_ScheduledJob")
shutdownJobToCreate = objShutdownJob.Create _
& ("Shutdown.exe", "********1800000.000000" & objTZoffsetMinutes, _
& False , , , , JobID)
Wscript.Echo shutdownJobCreated
'***********************************************************
Variable replacement will not work - keep getting an error that a ")" was
expected.
Any suggestions will be greatly appreciated.
Thanks in advance,
Bill Burke
bill@2burkes.com