Solved

WMI Privileges

Posted on 2004-04-29
7
947 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now