Wyman Wong
Wyman Wong

Reputation: 31

how can i pass argument for my startup application in registry run key

I developed an application of winform to automatically back up files on my computer.And this application has a startup argument "-autostart", if this application run with this argument, it will load the latest settings(of curse if run this application without this argument, it just run and don't load the latest settings.)

When i create a shortcut for this application with adding the "-autostart" argument, it just runs fine and load the settings. But i want this application to automatically run every time i start up my computer, so i create a run key in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] in my registry and the key value is "F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe" -autostart

But i didn't get what i want, it just didn't load the setting just as it was executed without the argument.I even blamed it on the position of the double quotation mark in the value so i tried the value "F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe -autostart" and F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe -autostart . BUT still the same.

So,how can i correctly pass the argument to the application in registry?

Upvotes: 1

Views: 3233

Answers (1)

J-DawG
J-DawG

Reputation: 1043

The argument must be preceded by a percent sign (%).

In your case, the registry key value needs to be:

F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe %autostart

Upvotes: 2

Related Questions