Re: WMI Logoff won't

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Scott,

I've tried adding the "WQL","0" as suggested. Rather than setting the
break point, I stepped through it with F8. This shows that the loop is
indeed entered, but only once. The particular line
"ObjOperatingSystem.Win32Shutdown nLogoff" is executed, but nothing
happens. Similarly the same invocation line specifying either reboot or
shutdown DOES work.

"Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23aAUgf1TFHA.2756@xxxxxxxxxxxxxxxxxxxxxxx
> It's working for me on WinXP SP2.
>
> Here is a possible cause, the default enumerator returrned is a Forward
> Only enumerator, so if you walk through the enumeration once, the 2nd time
> you walk through you may not get into the enumerator.
>
> I would try to set a breakpoint on the method call line and see if it
> hits.
>
> Also try to change this with the default flag being set to 32 forward
> only:
>> Set colOperatingSystems = objWMIService.ExecQuery("Select * from
>> Win32_OperatingSystem")
> to:
> Set colOperatingSystems = objWMIService.ExecQuery("Select * from
> Win32_OperatingSystem", "WQL", 0)
>
> --
> Scott McNairy
> Microsoft MVP - Windows Server Management Infrastructure
>
>
> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
> news:uOt8IuzTFHA.628@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> I have written a small VB6 program to allow a user the choice of
>> Logoff, Reboot, Shutdown, or Cancel. It uses the WMI method
>> objOperatingSystem.Win32Shutdown (parameter). All worked just fine on XP
>> SP1. When I installed XP SP2, the logoff option won't. The Shutdown and
>> Reboot are still working just fine. I've tried adding the "Force" to it
>> as well, no difference. Here's the relevant code:
>>
>> strComputer = "."
>> Set objWMIService =
>> GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\ _
>> " & strComputer & "\root\cimv2")
>> Set colOperatingSystems = objWMIService.ExecQuery("Select * from
>> Win32_OperatingSystem")
>>
>> ' This sub is invoked from a button on a form:
>>
>> Private Sub LogoffCmd_Click()
>> For Each ObjOperatingSystem In colOperatingSystems
>> ObjOperatingSystem.Win32Shutdown nLogoff <- nLogoff is defined
>> as "0"
>> Next
>> End Sub
>>
>> Any ideas whould be greatly appreciated.
>>
>> --
>> Tim.
>>
>
>


.


Quantcast