I think this has to do with the APIs that are used by WMI to initiate the Shutdown, and the special nature of TS sessions. The ExitWindowEX API, which I suspect WMI is calling under the covers, since it takes the same parameters as that function, only works for console sessions. However, TS sessions are special sessions and so aren't properly identified to that API. I took a quick look at the WMI provider for Terminal Server but as far as I can see all of the classes and methods there are meant for managing TS from the server side rather than the client. There is a Win32 API called WTSLogoffSession but you would have to write a utility to call it, which I think you were trying to avoid. In any case, its documented here: http://msdn.microsoft.com/library/default.asp?url="">
 
It seems like there should be an easy way to do this but as of yet, I haven't found it.
 
Darren

Hmm…You’re right…it works fine from the console.  Many of our admins logon through rdp though.  Is there a workaround for TS sessions?

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Darren Mar-Elia
Sent: Wednesday, December 14, 2005 2:16 PM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

 

Devon-

Are you getting an actual error or just that it doesn't work? I ran your script on my test W2003 box and it worked just fine. I ran it as administrator at the server's console. How are you running this script? At the console or in a TS session? The latter may be problematic. Also, you might want to try:

 

 objSystem.Win32Shutdown 4

 

which I think is forced logoff. That would get around issues where some process is preventing the normal logoff.

 

Darren

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Wednesday, December 14, 2005 9:52 AM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

Same error

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alain Lissoir
Sent: Wednesday, December 14, 2005 11:26 AM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

 

On 2003? Or 2000?

Hmmm ... can you try with this :) 

 

objWMILocator.Security_.Privileges.AddAsString "SeRemoteShutdownPrivilege", True

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Wednesday, December 14, 2005 7:39 AM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

I still get the same error running on a server:

 

Generic Error

 

It seem to be giving an error right at this point: objSystem.Win32Shutdown 0

 

Here is the whole script:

Set objWMILocator = CreateObject ("WbemScripting.SWbemLocator")

objWMILocator.Security_.Privileges.AddAsString "SeShutdownPrivilege", True

Set objWMIServices = objWMILocator.ConnectServer(strComputerName, cWMINameSpace, strUserID, strPassword)

 

Set objSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}").InstancesOf("Win32_OperatingSystem")

 

For Each objSystem In objSystemSet

        objSystem.Win32Shutdown 0

Next

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alain Lissoir
Sent: Wednesday, December 14, 2005 9:38 AM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

 

Have you tried your script as a plain admin on server? I wonder if it is not a question of privileges ...

 

Try to add to your script the following before connecting to the Root\CIMv2 namespace. Then retry ...

 

    Set objWMILocator=CreateObject ("WbemScripting.SWbemLocator")

    objWMILocator.Security_.Privileges.AddAsString "SeShutdownPrivilege", True

    Set objWMIServices = objWMILocator.ConnectServer(strComputerName, cWMINameSpace, strUserID, strPassword)

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Wednesday, December 14, 2005 5:23 AM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

This script is part of a another script that upon logon, checks certain registry values, then if the values are not set, the script then sets the value and logoff the current user.  Like I said before, it works on Windows XP but not servers.  Why?

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Shaff
Sent: Tuesday, December 13, 2005 7:38 PM
To: [email protected]
Subject: RE: [ActiveDir] Win32Shutdown Method & Win2003

 

The shutdown command works.  Give that a shot.

S

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Tuesday, December 13, 2005 2:34 PM
To: [email protected]
Subject: [ActiveDir] Win32Shutdown Method & Win2003

 

I’m using the following script to logoff a workstation.  It works fine on XP workstations but does not seem to work on Windows 2000/2003 servers.  Any Ideas?

 

Set objSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}").InstancesOf("Win32_OperatingSystem")

 

For Each objSystem In objSystemSet

        objSystem.Win32Shutdown 0

Next

 

Devon Harding

Windows Systems Engineer

Southern Wine & Spirits - BSG

954-602-2469

 


__________________________________
This message and any attachments are solely for the intended recipient
and may contain confidential or privileged information. If you are not
the intended recipient, any disclosure, copying, use or distribution of
the information included in the message and any attachments is
prohibited. If you have received this communication in error, please
notify us by reply e-mail and immediately and permanently delete this
message and any attachments. Thank You.

Reply via email to