Reboot...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I put some sample of code that was given here in the newsgroup

Dim ms As System.Management.ManagementScope = New System.Management.ManagementScope("\\LocalHost\root\cimv2"
Dim mo As System.Management.ManagementObjec

ms.Options.EnablePrivileges = Tru

' Verwende diesen Eigenschaften wenn es Probleme mit den Rechten gib
'ms.Options.Password = "
'ms.Options.Username = "

Dim oq As System.Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem"
Dim query1 As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher(ms, oq
Dim queryCollection1 As System.Management.ManagementObjectCollection = query1.Get(

For Each mo In queryCollection
'Dim ss As String() = {"2", "0"} ' Reboo
'Dim ss As String() = {"2", "2"} ' Logof
Dim ss As String() = {"2", "0"} ' Shutdow
mo.InvokeMethod("Win32Shutdown", ss
Nex

but gives me this message...."PREVILEGE NOT HELD"...Why is that
....Or there is other way to do the reboot

THANKS
 
Your process should held the SE_SHUTDOWN_NAME to be able to reboot the
system. Assuming the process is run under the interactive user (that is,
you), you should be granted permissions to reboot the system.

You can refer to the "ExitWindowsEx" topic in the Platform SDK docs for more
information (Windows System Information section).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Nuno said:
I put some sample of code that was given here in the newsgroup :

Dim ms As System.Management.ManagementScope = New System.Management.ManagementScope("\\LocalHost\root\cimv2")
Dim mo As System.Management.ManagementObject

ms.Options.EnablePrivileges = True

' Verwende diesen Eigenschaften wenn es Probleme mit den Rechten gibt
'ms.Options.Password = ""
'ms.Options.Username = ""

Dim oq As System.Management.ObjectQuery = New
System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem")
Dim query1 As System.Management.ManagementObjectSearcher = New
System.Management.ManagementObjectSearcher(ms, oq)
Dim queryCollection1 As
System.Management.ManagementObjectCollection = query1.Get()
 
Back
Top