Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - WMI Question

Reply
 
Old 04-06-2009   #1 (permalink)
Cary Shultz


 
 

WMI Question

Good evening!

I have a question: I know enough about WMI to know that adding the ", 48"
to WMI scripts is a good thing! However, I am having an issue when I add
this to the following script:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Explicit

Dim objWMIService, colServices, objFSO, objFile, objService
Dim strComputer

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where State = 'Paused' and StartMode =
'Auto'", 48)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("c:\resume-paused.txt")

For Each objService in colServices
objService.ResumeService()
objFile.WriteLine objService.displayName
Next

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

It gives me the following: c:\scripts>c:\scripts\scriptname.vbs (16,1)
(null): 0x80041018.

If I remove the , 48 at the end of the Query then everything runs without
issue. If I am not mistaken, the 0x80041018 = "query syntax is not valid".
What is wrong with my query syntax? BTW - I also get it if I leave off the
"Option Explicit" and DIM blah blah! at the top....

Thanks,

Cary


My System SpecsSystem Spec
Old 04-06-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: WMI Question

Cary Shultz wrote:
Quote:

> I have a question: I know enough about WMI to know that adding the ", 48"
> to WMI scripts is a good thing! However, I am having an issue when I add
> this to the following script:
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Option Explicit
>
> Dim objWMIService, colServices, objFSO, objFile, objService
> Dim strComputer
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colServices = objWMIService.ExecQuery _
> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
> 'Auto'", 48)
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFile = objFSO.CreateTextFile("c:\resume-paused.txt")
>
> For Each objService in colServices
> objService.ResumeService()
> objFile.WriteLine objService.displayName
> Next
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> It gives me the following: c:\scripts>c:\scripts\scriptname.vbs (16,1)
> (null): 0x80041018.
>
> If I remove the , 48 at the end of the Query then everything runs without
> issue. If I am not mistaken, the 0x80041018 = "query syntax is not
> valid". What is wrong with my query syntax? BTW - I also get it if I
> leave off the "Option Explicit" and DIM blah blah! at the top....
>
> Thanks,
The flag, 48, should be the third parameter, with the second parameter
blank:

Set colServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where State = 'Paused' and StartMode =
'Auto'", ,48)

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 04-06-2009   #3 (permalink)
Cary Shultz


 
 

Re: WMI Question

Auch, Du Schande!!!!!!! I missed a comma! I spent two hours trying to
figure that out. I guess that I should not admit to that in public, huh? I
should have known that one!

Thank you!

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:O5tHK6ytJHA.4452@xxxxxx
Quote:

> Cary Shultz wrote:
>
Quote:

>> I have a question: I know enough about WMI to know that adding the ",
>> 48" to WMI scripts is a good thing! However, I am having an issue when I
>> add this to the following script:
>>
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Option Explicit
>>
>> Dim objWMIService, colServices, objFSO, objFile, objService
>> Dim strComputer
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:" _
>> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>>
>> Set colServices = objWMIService.ExecQuery _
>> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
>> 'Auto'", 48)
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objFile = objFSO.CreateTextFile("c:\resume-paused.txt")
>>
>> For Each objService in colServices
>> objService.ResumeService()
>> objFile.WriteLine objService.displayName
>> Next
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> It gives me the following: c:\scripts>c:\scripts\scriptname.vbs (16,1)
>> (null): 0x80041018.
>>
>> If I remove the , 48 at the end of the Query then everything runs without
>> issue. If I am not mistaken, the 0x80041018 = "query syntax is not
>> valid". What is wrong with my query syntax? BTW - I also get it if I
>> leave off the "Option Explicit" and DIM blah blah! at the top....
>>
>> Thanks,
>
> The flag, 48, should be the third parameter, with the second parameter
> blank:
>
> Set colServices = objWMIService.ExecQuery _
> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
> 'Auto'", ,48)
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
My System SpecsSystem Spec
Old 04-06-2009   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: WMI Question


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:O5tHK6ytJHA.4452@xxxxxx
Quote:

> Cary Shultz wrote:
>
Quote:

>> I have a question: I know enough about WMI to know that adding the ",
>> 48" to WMI scripts is a good thing! However, I am having an issue when I
>> add this to the following script:
>>
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Option Explicit
>>
>> Dim objWMIService, colServices, objFSO, objFile, objService
>> Dim strComputer
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:" _
>> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>>
>> Set colServices = objWMIService.ExecQuery _
>> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
>> 'Auto'", 48)
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objFile = objFSO.CreateTextFile("c:\resume-paused.txt")
>>
>> For Each objService in colServices
>> objService.ResumeService()
>> objFile.WriteLine objService.displayName
>> Next
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> It gives me the following: c:\scripts>c:\scripts\scriptname.vbs (16,1)
>> (null): 0x80041018.
>>
>> If I remove the , 48 at the end of the Query then everything runs without
>> issue. If I am not mistaken, the 0x80041018 = "query syntax is not
>> valid". What is wrong with my query syntax? BTW - I also get it if I
>> leave off the "Option Explicit" and DIM blah blah! at the top....
>>
>> Thanks,
>
> The flag, 48, should be the third parameter, with the second parameter
> blank:
>
> Set colServices = objWMIService.ExecQuery _
> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
> 'Auto'", ,48)
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
See this link:

http://msdn.microsoft.com/en-us/library/aa393866.aspx

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 04-06-2009   #5 (permalink)
Cary Shultz


 
 

Re: WMI Question

Yes, I remember that one. Torgier showed me a few years ago. I simply - in
my haste - overlooked the missing comma (position).

Thank you for the link, though. I have saved it as a favorite! I will not
make this mistake again!

Cary

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:evpbiAztJHA.5664@xxxxxx
Quote:

>
> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
> message news:O5tHK6ytJHA.4452@xxxxxx
Quote:

>> Cary Shultz wrote:
>>
Quote:

>>> I have a question: I know enough about WMI to know that adding the ",
>>> 48" to WMI scripts is a good thing! However, I am having an issue when
>>> I add this to the following script:
>>>
>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> Option Explicit
>>>
>>> Dim objWMIService, colServices, objFSO, objFile, objService
>>> Dim strComputer
>>>
>>> strComputer = "."
>>> Set objWMIService = GetObject("winmgmts:" _
>>> & "{impersonationLevel=impersonate}!\\" & strComputer &
>>> "\root\cimv2")
>>>
>>> Set colServices = objWMIService.ExecQuery _
>>> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
>>> 'Auto'", 48)
>>>
>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>> Set objFile = objFSO.CreateTextFile("c:\resume-paused.txt")
>>>
>>> For Each objService in colServices
>>> objService.ResumeService()
>>> objFile.WriteLine objService.displayName
>>> Next
>>>
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>
>>> It gives me the following: c:\scripts>c:\scripts\scriptname.vbs (16,1)
>>> (null): 0x80041018.
>>>
>>> If I remove the , 48 at the end of the Query then everything runs
>>> without issue. If I am not mistaken, the 0x80041018 = "query syntax is
>>> not valid". What is wrong with my query syntax? BTW - I also get it if
>>> I leave off the "Option Explicit" and DIM blah blah! at the top....
>>>
>>> Thanks,
>>
>> The flag, 48, should be the third parameter, with the second parameter
>> blank:
>>
>> Set colServices = objWMIService.ExecQuery _
>> ("Select * from Win32_Service Where State = 'Paused' and StartMode =
>> 'Auto'", ,48)
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>
> See this link:
>
> http://msdn.microsoft.com/en-us/library/aa393866.aspx
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
IE8 Question Vista General
escape character question - hopefully an easy question PowerShell
vista genral question and ultimate question Vista General
Dual boot system question and family deal discount question Vista General
RC1 Cd Key Question Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46