473,504 Members | 13,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set previlege with Windows Management

Hi,

Here is text copy/paste from the WMI SDK reference

Use the Win32_OperatingSystem class and the Win32Shutdown method. You must
include the RemoteShutdown privilege when connecting to WMI. For more
information, see Executing Privileged Operations. Unlike the Shutdown method
on Win32_OperatingSystem, the Win32Shutdown method allows you to set flags to
control the shutdown behavior.
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Shutdown(1)
Next
My question is what is the equivalent of
"{impersonationLevel=impersonate,(Shutdown)}!\ \" in .NET/C#. Is setting
EnablePrivilege = true good enough?

Thanks.
Jul 21 '05 #1
3 2661
Yes, setting EnablePrivilege to "true" should 'enable' all privileges
required to execute a specific WMI class methods.
Note that the principal must have been granted the required privilege (see
local security policies).

Note however that this fails when run on .NET v1.1 SP1.

Willy.
PS.Please post System.Management (WMI) related questions to
microsoft.public.dotnet.framework.wmi.

Willy.

"David Shen" <Da*******@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Hi,

Here is text copy/paste from the WMI SDK reference

Use the Win32_OperatingSystem class and the Win32Shutdown method. You must
include the RemoteShutdown privilege when connecting to WMI. For more
information, see Executing Privileged Operations. Unlike the Shutdown
method
on Win32_OperatingSystem, the Win32Shutdown method allows you to set flags
to
control the shutdown behavior.
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Shutdown(1)
Next
My question is what is the equivalent of
"{impersonationLevel=impersonate,(Shutdown)}!\ \" in .NET/C#. Is setting
EnablePrivilege = true good enough?

Thanks.

Jul 21 '05 #2


"David Shen" <Da*******@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Hi Willy,

Thanks for the reply.

You mentioned "Note however that this fails when run on .NET v1.1 SP1."

So what is the "suggested" approach that works both now and with .NET v1.1
SP1?

Or is the SP1 considered a new version that will be installed side-by-side
with v1.1 so the current codes will continue to run with v1.1?

David,

SP1 is a service pack for .NET v1.1 not a new version of 1.1, so it wont run
side-by-side.
Search the microsoft.public.dotnet.framework.wmi for a bypass I posted for
this issue

Willy.
Jul 21 '05 #3
Hi Willy,

Thanks for the reply.

You mentioned "Note however that this fails when run on .NET v1.1 SP1."

So what is the "suggested" approach that works both now and with .NET v1.1
SP1?

Or is the SP1 considered a new version that will be installed side-by-side
with v1.1 so the current codes will continue to run with v1.1?

Best,

David

"Willy Denoyette [MVP]" wrote:
Yes, setting EnablePrivilege to "true" should 'enable' all privileges
required to execute a specific WMI class methods.
Note that the principal must have been granted the required privilege (see
local security policies).

Note however that this fails when run on .NET v1.1 SP1.

Willy.
PS.Please post System.Management (WMI) related questions to
microsoft.public.dotnet.framework.wmi.

Willy.

"David Shen" <Da*******@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Hi,

Here is text copy/paste from the WMI SDK reference

Use the Win32_OperatingSystem class and the Win32Shutdown method. You must
include the RemoteShutdown privilege when connecting to WMI. For more
information, see Executing Privileged Operations. Unlike the Shutdown
method
on Win32_OperatingSystem, the Win32Shutdown method allows you to set flags
to
control the shutdown behavior.
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Shutdown(1)
Next
My question is what is the equivalent of
"{impersonationLevel=impersonate,(Shutdown)}!\ \" in .NET/C#. Is setting
EnablePrivilege = true good enough?

Thanks.


Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7187
by: Colin Brown | last post by:
Recently I was looking for remote management tools and came across "Windows Management Instrumentation". There is a python interface available: http://tgolden.sc.sabren.com/python/wmi.html I...
16
34535
by: Robert Mark Bram | last post by:
Hi All! Is there a way to reference a window by name without doing something like this: open (, 'windowName'); The open method will open a blank window if there is no window with such a name....
0
1912
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
2
11388
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
10
3462
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
2
5911
by: Chris Podmore | last post by:
I don't know if this is the correct newsgroup but I couldn't find one for Windows Services Is it possible to check that a Windows Service is still running from another machine The idea being a...
2
286
by: David Shen | last post by:
Hi, Here is text copy/paste from the WMI SDK reference Use the Win32_OperatingSystem class and the Win32Shutdown method. You must include the RemoteShutdown privilege when connecting to WMI....
1
3643
by: =?Utf-8?B?UGllcnJl?= | last post by:
Hello, I have an simle application that uses a referenced library of my own. It's been a year now that I have no problems until a few days. Here is the details of my problem: The library...
2
4757
by: Vadim Malishev | last post by:
Hello, Can anybody help to solve the following problem? My Windows Service trying to access remote machine to get WindowsDirectory Property over Win32_OperatingSystem WMI class. Both servers...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.