Solved

WMI Privileges

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared 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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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