0

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

ssd
  • 2,340
  • 5
  • 19
  • 37
JaviR3TicS
  • 35
  • 5
  • Do you really need to write your own application, or you just need an `.exe` file to have whatever McMyAdmin is execute? If the latter, as both answers reference there is the built-in Windows executable [`shutdown.exe`](https://docs.microsoft.com/windows-server/administration/windows-commands/shutdown), which you could use to shut down the computer with `shutdown /s`. Also, no one should have to download an expiring `.rar` file from a third-party server to see your code. Please provide the relevant parts in the question itself, otherwise it's impossible to diagnose your error message. – Lance U. Matthews Apr 02 '20 at 19:29

1 Answers1

0
"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

ryyker
  • 22,849
  • 3
  • 43
  • 87