Coding Horror posted by:
Rajkatie | Posted on: 3/3/2012 | Category:
C# | Views: 3017 | Level:
Silver | Status:
[Member] |
Points: 75
|
Alert Moderator
public void PerformOperation(string filename, string arguments)
{
using (Process myProcess = new Process())
{
myProcess.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, filename);
myProcess.StartInfo.Arguments = arguments;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
// lock computer
1) PerformOperation("rundll32.exe", "user32.dll,LockWorkStation");
//Log Off computer
2)PerformOperation("shutdown.exe", "-l");
//Restart computer
3)PerformOperation("shutdown.exe", "-r -t 0");
//Shutdown computer
4)ProcessRequest("shutdown.exe", "-s -t 0");
Rajesh Patel
MCPD,MS
Brainbench (Asp.Net 4.0 and CSS 3.0)
Found interesting? Add this to: