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

Re: Stumped !! by Michael

Michael
Tue Sep 16 21:33:21 CDT 2003

Bill wrote:
> 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" &
^
|
+--------- What's with the & ???



> 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

--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

System Administration Scripting Guide - samples scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: Stumped !! by Bill

Bill
Tue Sep 16 22:17:05 CDT 2003

Michael,

The "&" you point to below is to concatenate the two lines. In my "real" script
the entire line is on one line - and the script still fails.

Do you see anything else wrong with the script?

Thanks in advance,
Bill Burke

In article <eeJ4PQMfDHA.3204@TK2MSFTNGP11.phx.gbl>, MVP\ says...
>
>Bill wrote:
>> 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" &
> ^
> |
> +--------- What's with the & ???
>
>
>
>> 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
>
>--
>Michael Harris
>Microsoft.MVP.Scripting
>
>Windows 2000 Scripting Guide
>Microsoft® Windows®2000 Scripting Guide
>http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
>
>System Administration Scripting Guide - samples scripts
>http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
>
>WSH 5.6 documentation download
>http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
>


Re: Stumped !! by Michael

Michael
Tue Sep 16 23:03:43 CDT 2003

Bill wrote:
> Michael,
>
> The "&" you point to below is to concatenate the two lines. In my
> "real" script
> the entire line is on one line - and the script still fails.


Post the *real* script as a TXT file attachment...


>
> Do you see anything else wrong with the script?
>


--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

System Administration Scripting Guide - samples scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: Stumped !! by Gurgen

Gurgen
Tue Sep 16 23:18:44 CDT 2003


"Bill" <Bill_member@newsguy.com> wrote in message news:bk87kc0v97@drn.newsguy.com...
> 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.

This is a script syntax error (it usually shows you line with error). Check the real script for similar errors as Michael pointed
(incorrect concatenation).
Otherwise there is nothing wrong with the script. I tried it and it works fine.

Gurgen.

> Any suggestions will be greatly appreciated.
>
> Thanks in advance,
> Bill Burke
> bill@2burkes.com
>



Re: Stumped !! by Michael

Michael
Tue Sep 16 23:24:41 CDT 2003

Bill wrote:
> Michael,
>
> The "&" you point to below is to concatenate the two lines. In my
> "real" script
> the entire line is on one line - and the script still fails.
>
> Do you see anything else wrong with the script?

...
..
.
shutdownJobCreated = objShutdownJob.Create(_
"Shutdown.exe", _
"********180000.000000" & objTZoffsetMinutes, _
False, , , , JobID)

I also fixed the time to 180000.000000 (you had 1800000.000000 - one too
many 0's after the 18)...

--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

System Administration Scripting Guide - samples scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: Stumped !! by Bill

Bill
Wed Sep 17 21:49:58 CDT 2003

Michael,

Thanks for your help!

I'm hesitant to post the entire script publicly. I'd like for you to look at my
script and give me an honest appraisal.... If you're so inclined, please email
me (mirhar@mvps.org doesn't work) and I'll send you the script.

Thanks again,
Bill Burke
bill@2burkes.com


In article <OXVqeONfDHA.164@tk2msftngp13.phx.gbl>, MVP\ says...
>
>Bill wrote:
>> Michael,
>>
>> The "&" you point to below is to concatenate the two lines. In my
>> "real" script
>> the entire line is on one line - and the script still fails.
>>
>> Do you see anything else wrong with the script?
>
>...
>..
>.
>shutdownJobCreated = objShutdownJob.Create(_
> "Shutdown.exe", _
> "********180000.000000" & objTZoffsetMinutes, _
> False, , , , JobID)
>
>I also fixed the time to 180000.000000 (you had 1800000.000000 - one too
>many 0's after the 18)...
>
>--
>Michael Harris
>Microsoft.MVP.Scripting
>
>Windows 2000 Scripting Guide
>Microsoft® Windows®2000 Scripting Guide
>http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
>
>System Administration Scripting Guide - samples scripts
>http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
>
>WSH 5.6 documentation download
>http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
>


Re: Stumped !! by Michael

Michael
Wed Sep 17 22:42:23 CDT 2003

> ... (mirhar@mvps.org doesn't work) and I'll send you the script.

That's mikhar@mvps.org ...

--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

System Administration Scripting Guide - samples scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en