I need help in trying to execute an executable from my C# application.
Suppose the path is cPath
, the EXE is HHTCtrlp.exe
and the parameter that has to be passed is cParams
.
How would I go about this?
The reason why the path is a variable is that there are 3 different EXE files to run and the path will change depending on which one will run, same with the parameter string.
Any help would be greatly appreciated.
To add launch parameters to the shortcut, click or tap inside the Target text field, and type all the arguments you want to add to it, at the end of the line. Each of the additional launch parameters must be preceded by a blank space and a hyphen.
You can run exe files in powershell different ways. For instance if you want to run unrar.exe and extract a . rar file you can simply write in powershell this: $extract_path = "C:\Program Files\Containing folder"; $rar_to_extract = "C:\Path_to_arch\file.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
To start the process with parameters, you can use following code:
string filename = Path.Combine(cPath,"HHTCtrlp.exe"); var proc = System.Diagnostics.Process.Start(filename, cParams);
To kill/exit the program again, you can use following code:
proc.CloseMainWindow(); proc.Close();
System.Diagnostics.Process.Start("PATH to exe", "Command Line Arguments");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With