+ 2
how to write a code in c# to shutdown the computer(windows xp)?
2 Respuestas
+ 4
var psi = new ProcessStartInfo("shutdown","-s -t 00");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
0
Lock the computer in C#
using(Process proc = new Process())
{
proc.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "rundll32.exe");
proc.StartInfo.Arguments = "user32.dll,LockWorkStation";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
}
Logoff the computer in C#
using(Process proc = new Process())
{
proc.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "shutdown.exe");
proc.StartInfo.Arguments = "-l";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
}
Restart the computer in C#
using(Process proc = new Process())
{
proc.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "shutdown.exe");
proc.StartInfo.Arguments = "-r -t 0";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
}
Shutdown the computer in C#
using(Process proc = new Process())
{
proc.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "shutdown.exe");
proc.StartInfo.Arguments = "-s -t 0";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
}