How can I launch an application using C#?
Requirements: Must work on Windows XP and Windows Vista.
I have seen a sample from DinnerNow.net sampler that only works in Windows Vista.
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.
FileName = "dcm2jpg.exe"; startInfo. WindowStyle = ProcessWindowStyle. Hidden; startInfo. Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close.
After you download your desired exe on your Android phone, download and install Inno Setup Extractor from the Google Play Store, use a file browser to locate the exe file, and open that file with the app. Inno Setup Extractor will then extract the exe on your Android phone, and you can check out those files afterward.
Use System.Diagnostics.Process.Start()
method.
Check out this article on how to use it.
Process.Start("notepad", "readme.txt"); string winpath = Environment.GetEnvironmentVariable("windir"); string path = System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath); Process.Start(winpath + @"\Microsoft.NET\Framework\v1.0.3705\Installutil.exe", path + "\\MyService.exe");
Here's a snippet of helpful code:
using System.Diagnostics; // Prepare the process to run ProcessStartInfo start = new ProcessStartInfo(); // Enter in the command line arguments, everything you would enter after the executable name itself start.Arguments = arguments; // Enter the executable to run, including the complete path start.FileName = ExeName; // Do you want to show a console window? start.WindowStyle = ProcessWindowStyle.Hidden; start.CreateNoWindow = true; int exitCode; // Run the external process & wait for it to finish using (Process proc = Process.Start(start)) { proc.WaitForExit(); // Retrieve the app's exit code exitCode = proc.ExitCode; }
There is much more you can do with these objects, you should read the documentation: ProcessStartInfo, Process.
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