VFP9, Windows 2000 or Windows XP. Any safe way to determine if WMI service
is running before I call something like:


loWMIService = GetObject("winmtmts://"+lcComputer+"/root/cimv2" &&
error occurs here
loProcesses = loWMIService.ExecQuery("SELECT * FROM Win32_Process")I am
putting it inside of a TRY...ENDTRY but it doesn't prevent the Moniker
Cannot Open File error...

I am trying to determing if the service is not running, is corrupt, or if
the user doesn't have the security permissions necessary to see WMI and run
ExecQuery. I would like to verify WMI is running, then check for the rights
to run execquery...

Re: WMI Service is Running? by Roger

Roger
Thu Sep 27 06:54:17 PDT 2007


"holzert" <holzert@nc.rr.com> wrote in message news:uo7MfqQAIHA.4496@TK2MSFTNGP06.phx.gbl...
> VFP9, Windows 2000 or Windows XP. Any safe way to determine if WMI service is running before I
> call something like:
>
>
> loWMIService = GetObject("winmtmts://"+lcComputer+"/root/cimv2" && error occurs here

Before we go any further, there's a typo in your code.

"winmtmts" should be "winmgmts"

-Roger




Re: WMI Service is Running? by holzert

holzert
Thu Sep 27 07:48:19 PDT 2007

Yes, thank you and sorry about that. An MVP gave me the solution:

*--Courtesy Sergey Berezniker 09/27/2007
oShellApp = CreateObject("Shell.Application")>>lcServiceName = "winmgmt"
? oShellApp.IsServiceRunning(lcServiceName)

For any lurkers interested.






"Roger Ansell" <notmy@realemailaddress.net> wrote in message
news:eKmbqzQAIHA.4200@TK2MSFTNGP04.phx.gbl...
>
> "holzert" <holzert@nc.rr.com> wrote in message
> news:uo7MfqQAIHA.4496@TK2MSFTNGP06.phx.gbl...
>> VFP9, Windows 2000 or Windows XP. Any safe way to determine if WMI
>> service is running before I call something like:
>>
>>
>> loWMIService = GetObject("winmtmts://"+lcComputer+"/root/cimv2"
>> && error occurs here
>
> Before we go any further, there's a typo in your code.
>
> "winmtmts" should be "winmgmts"
>
> -Roger
>
>
>