Solved

WMI Privileges

Posted on 2004-04-29
7
956 Views
Last Modified: 2013-12-03
Hi,
my domain users have policies to run logon logoff vbs script. I must denied logon for some users.
This is the code:
......
For Each os In GetObject("winmgmts:{impersonationLevel=impersonate,(shutdown,remoteshutdown)}!//" +        
                objNet.Computername).InstancesOf("Win32_OperatingSystem")
         retCode = os.Win32Shutdown(4, 0)
Next
......
objNet.Computername is the PC to shutdown.

When the administrator runs the code, the pc shutdown normally. Any other user get this error message:

Code 80041062, privilege not available. (iswbemobject)

The error is on the line retCode = os.Win32Shutdown(4, 0)

With DCOMCNFG everything seems OK for the application Windows Management Instrumentation.

Any suggestion?

Thank you
0
Comment
Question by:Meronic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 10950328
Are you sure that the 'Shutdown computer' privilege is granted to these users?
0
 

Author Comment

by:Meronic
ID: 10950640
I'm sorry; not shutdown computer but logoff; Users does not have privilege to shutdown computer and I don't want to assign them the right.


os.Win32Shutdown(4, 0)
4 means logoff, right??


Thanks
0
 
LVL 86

Expert Comment

by:jkr
ID: 10950799
See http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32shutdown_method_in_class_win32_operatingsystem.asp ("Win32Shutdown Method of the Win32_OperatingSystem Class") - it clearly states that "On computer systems running Windows® NT/Windows 2000, the calling process must have the SE_SHUTDOWN_NAME privilege", regardless of what the parameters are...
0
 

Author Comment

by:Meronic
ID: 10951478
How can I verify the process privilege?
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 10951971
I am not too familiar with WMI, but http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_privilegesstatus.asp ("Win32_PrivilegesStatus") should help.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question