How can I pass an argument for my application launch to the registry start key

I developed a winform application for automatically backing up files on my computer. And this application has the start argument "-autostart", if this application starts with this argument, it will load the latest settings (damn it, if you run this application without this argument, it just starts and does not load the latest settings.)

When I create a shortcut for this application with the addition of the "-autostart" argument, it just works fine and loads the settings. But I want this application to start automatically every time my computer starts, so I create a startup 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 parameter in the same way as it was executed without an argument. I even accused him of double-quoting 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 all the same.

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

0
source share
1 answer

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

In your case, the registry key value should be:

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

0
source

All Articles