I want to make an exe app that shutdown Windows. It's for starting it from McMyAdmin 2. How can I do it? (I've tried it making this app (Shutdown Visual Studio Project and EXE), but I get this error:
The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at McMyAdmin.TimedEvents.DoExec(String EventData, Boolean SendToConsole, String Args)
Could you help me? Thanks! Javier
"I want to make an exe app that shutdown Windows."
These code examples (Both Linux and Windows.) are bare-boned examples from the link below. You will have to consider that the programs need to be executed with sufficient privileges, along with several other things for them to work as you would like...
In Windows:
EDIT (after tag change from C
to C#
C# - you can use this with any Windows utility exe:
Process.Start("application.exe", "param1 param2");
eg.
Process.Start("c:\\windows\\system32\\shutdown.exe", "/s");
For ANSI C -
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
system("c:\\windows\\system32\\shutdown /s"); //simple shutdown
return 0;
}
Other commands:
system("c:\\windows\\system32\\shutdown /i"); //shutdown with GUI
system("c:\\windows\\system32\\shutdown /r"); //Restart
system("c:\\windows\\system32\\shutdown /l"); //Logoff
Note: These Windows shutdown commands may bring up a dialog box requiring user to enter PC name. If you want to automate populating the dialog box, command switches will help:
Open a cmd prompt in Windows and type "help shutdown" to get this information
More information here