Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

shutdown system C#

Process.Start("shutdown","/s /t 0");
Comment

shutdown system C#

var psi = new ProcessStartInfo("shutdown","/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
// to avoid creating window
Comment

shutdown system C#


using System.Management;

void Shutdown()
{
    ManagementBaseObject mboShutdown = null;
    ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem");
    mcWin32.Get();

    // You can't shutdown without security privileges
    mcWin32.Scope.Options.EnablePrivileges = true;
    ManagementBaseObject mboShutdownParams =
             mcWin32.GetMethodParameters("Win32Shutdown");

     // Flag 1 means we want to shut down the system. Use "2" to reboot.
    mboShutdownParams["Flags"] = "1";
    mboShutdownParams["Reserved"] = "0";
    foreach (ManagementObject manObj in mcWin32.GetInstances())
    {
        mboShutdown = manObj.InvokeMethod("Win32Shutdown", 
                                       mboShutdownParams, null);
    }
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: vs code explorer font size 
Csharp :: countdown timer c# unity 
Csharp :: remove end character of string c# 
Csharp :: c# how to output in between 0 - 100 in an int array 
Csharp :: byte to stream c# 
Csharp :: c# unity destroy first child object 
Csharp :: maxheap c# 
Csharp :: turtle graphics face in direction 
Csharp :: c# open file in default program 
Csharp :: animations for pause menu 
Csharp :: unity how to rotate something to point to something else 
Csharp :: c# thread wait 
Csharp :: c# add guid to array 
Csharp :: iactionresult 
Csharp :: How can I cast string to enum? 
Csharp :: unity get a position inside sphere 
Csharp :: canty obituary schenectady ny 
Csharp :: how to parse a string to an integer c# 
Csharp :: how to split list by date c# 
Csharp :: How to add a label programatically in c# 
Csharp :: c# read char 
Csharp :: how to add reference to rigidbody 2d 
Csharp :: unity check load scene 
Csharp :: c# check if string is only letters and numbers 
Csharp :: c# linq to dictionary 
Csharp :: unity dictionary check if key exists 
Csharp :: Check if two linked lists merge. If so, where? 
Csharp :: how to make a enum list in c# 
Csharp :: convert text to number c# 
Csharp :: c# timer 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =