Re: WMI Logoff won't



When you are logged in as the user you are having this trouble with does
normal logoff sequence work?

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure


"Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
news:O72maR6WFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
>
> It was 1702. All three functions reported 1702. Shutdown, and reboot
> both work, but Logoff doesn't.
>
> --
> Tim
>
> "Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:OkIlsYxWFHA.3280@xxxxxxxxxxxxxxxxxxxxxxx
>> Was the out parameter the same as 1702 or different?
>>
>> --
>> Scott McNairy
>> Microsoft MVP - Windows Server Management Infrastructure
>>
>>
>> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
>> news:uM0zQTkWFHA.2348@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hi Scott,
>>>
>>> No the script does not work on the failing machine.
>>>
>>> --
>>> Tim.
>>>
>>> "Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in message
>>> news:u%23g6xYxVFHA.2796@xxxxxxxxxxxxxxxxxxxxxxx
>>>>I doubt that is the cause of this problem.
>>>>
>>>> Does the script that I provided work on the failing machine?
>>>>
>>>> --
>>>> Scott McNairy
>>>> Microsoft MVP - Windows Server Management Infrastructure
>>>>
>>>>
>>>> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
>>>> news:%23v4tGpuVFHA.1384@xxxxxxxxxxxxxxxxxxxxxxx
>>>>> Scott,
>>>>> More info. As a test I ran this on a different machine. Lo and
>>>>> behold, it works just fine (and the return value was 0). Is there a
>>>>> registry setting that could prevent the logoff function from
>>>>> executing? I have removed "Logoff" from the start menu in an effort to
>>>>> get students to use my program instead. Could this be part of my
>>>>> problem?
>>>>>
>>>>> --
>>>>> Tim
>>>>>
>>>>> "Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in message
>>>>> news:OPOZqxkVFHA.2700@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>> That returnvalue means that "The binding handle is invalid." to quote
>>>>>> the error text as per the "Error Lookup" tool included with Visual
>>>>>> Studio.
>>>>>>
>>>>>> I suspect that this is due to the enumerator being populated outside
>>>>>> the scope of the form object. I can take a look at VB6 code if you
>>>>>> feel like putting it on the newsgroup (please zip it up if you decide
>>>>>> to).
>>>>>>
>>>>>> --
>>>>>> Scott McNairy
>>>>>> Microsoft MVP - Windows Server Management Infrastructure
>>>>>>
>>>>>>
>>>>>> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
>>>>>> news:uPrPQ%23iVFHA.628@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>>> The ReturnValue I get is "1702"
>>>>>>>
>>>>>>> --
>>>>>>> Tim
>>>>>>>
>>>>>>> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
>>>>>>> news:evuz1IiVFHA.2700@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>>>> I've already tried the "ForceLogoff" with no difference.
>>>>>>>> I'll give your script a shot, thanks.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Tim
>>>>>>>>
>>>>>>>> "Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in
>>>>>>>> message news:utIskoLVFHA.3444@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>>>>> Can you try this script and see if the returnValue that get's
>>>>>>>>> echo'ed out is nonzero and post the result if it is? In addition,
>>>>>>>>> try to modify the nLogoff from 0 to 4 and see if that does the
>>>>>>>>> trick for you.
>>>>>>>>>
>>>>>>>>> strComputer = "."
>>>>>>>>> nLogoff = 0
>>>>>>>>> Set objWMIService =
>>>>>>>>> GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\"
>>>>>>>>> & strComputer & "\root\cimv2")
>>>>>>>>> Set colOperatingSystems = objWMIService.ExecQuery("Select * from
>>>>>>>>> Win32_OperatingSystem")
>>>>>>>>>
>>>>>>>>> dim outParams, inParams
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> For Each ObjOperatingSystem In colOperatingSystems
>>>>>>>>> set inParams =
>>>>>>>>> objOperatingSystem.Methods_("Win32Shutdown").InParameters.SpawnInstance_()
>>>>>>>>> inParams.Flags = nLogoff
>>>>>>>>>
>>>>>>>>> set OutParams = ObjOperatingSystem.ExecMethod_("Win32Shutdown",
>>>>>>>>> inParams)
>>>>>>>>>
>>>>>>>>> wscript.echo outParams.ReturnValue
>>>>>>>>>
>>>>>>>>> Next
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Scott McNairy
>>>>>>>>> Microsoft MVP - Windows Server Management Infrastructure
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "Tim Munro" <Excelsior@xxxxxxxxxxx> wrote in message
>>>>>>>>> news:ONMMAYKVFHA.4092@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>>>>>> 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.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


.


Loading