Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! Newbie inquiring help in C# here ^^"

So I'd like to learn if there's a way to start processes with "special settings in the end" (I have no idea what to call it) with C#.

An example of what I mean would be that if you add "-window" at the end of your WarCraft III shortcut target, the game will be run in windowed mode.
(So if you go to properties of the warcraft III shortcut, the target will display '"C:\Games\Warcraft III\Warcraft III.exe" -window')

I hope you understand what I mean, please ask if it's unclear.

Best regards
-Mossmyr
Posted

You talk about parameters;

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = @"C:\Games\Warcraft III\Warcraft III.exe";
process.StartInfo.Arguments = "window";
process.UseShellExecute = false;
process.Start();
 
Share this answer
 
Comments
Mossmyr 1-May-12 10:46am    
I'm missing the System.Diagnostics.Process.UseShellExecute method (I am using System.Diagnostics).
Not having it there does start the game, but not in windowed mode :/
Yes - it's the parameters, or program arguments:
C#
Process.Start(@"C:\Games\Warcraft III\Warcraft III.exe","-window");
 
Share this answer
 
Comments
Mossmyr 1-May-12 10:44am    
Worked perfectly, thank you.
OriginalGriff 1-May-12 10:50am    
You're welcome!
These settings are called command line arguments. You can get these arguments using Environment.GetCommandLineArgs();[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900