How do I write a very simple program that uses the command line to navigate to a program in the user's Program Files directory, then launches the .exe
with a parameter? For example:
"C:\etc\Program Files\ProgramFolder\Program.exe C:\etc\desktop\file.spp C\etc\desktop\file.txt"
This launches a program with a certain project file and a .txt
file along with it.
Select More >> Open File Location from within the drop-down menu. Right-click on the first associated application shortcut (repeat the next three steps for all associated application shortcuts). Select Properties from the drop-down menu. Record the parameter value for future use.
option. You can test command line arguments by running an executable from the "Command Prompt" in Windows or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run.
In the right pane, right-click SQL Server (<instance_name>), and then click Properties. On the Startup Parameters tab, in the Specify a startup parameter box, type the parameter, and then click Add. For example, to start in single-user mode, type -m in the Specify a startup parameter box and then click Add.
A command line argument is simply anything we enter after the executable name, which in the above example is notepad.exe. So for example, if we launched Notepad using the command C:\Windows\System32\notepad.exe /s, then /s would be the command line argument we used.
You can use the ProcessStartInfo.Arguments property to specify the string of arguments for your program:
ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = @"C:\etc\Program Files\ProgramFolder\Program.exe"; startInfo.Arguments = @"C:\etc\desktop\file.spp C:\etc\desktop\file.txt"; Process.Start(startInfo);
Just create a new text file, name it "go.cmd" and put the following in there:
"C:\etc\Program Files\ProgramFolder\Program.exe C:\etc\desktop\file.spp C\etc\desktop\file.txt"
Voila, you have your program!
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