Reputation: 6492
I have been wondering how to provide command line arguments to a application on startup.
I mean what to type in the code, so that a registry entry is created which supplies the command line args:- I have been using the following code, to create a registry entry(so that application launches on startup.
using Microsoft.Win32;
private void SetStartup()
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.SetValue(AppName, Application.ExecutablePath.ToString());
}
Can anyone tell me what parameter I should modify in
rk.SetValue()
function's arguments to supply command line arguements to my app.
Upvotes: 1
Views: 5556
Reputation: 492
If I understund correct you want add command line arguments when your application startup on windows boot?
Then you must do something like that:
string cmd = Application.ExecutablePath.ToString() + " /arg1 /arg2 /arg3 .....";
RegistryKey rk = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.SetValue(AppName, cmd);
Upvotes: 4
Reputation: 783
You can use: Project Properties--> Debug-->Command Line Argument, then use these arguments from args in Main(string[] args)
Upvotes: 0