如何在注册表运行键中为我的启动应用程序传递参数 [英] how can i pass argument for my startup application in registry run key

查看:49
本文介绍了如何在注册表运行键中为我的启动应用程序传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个winform的应用程序来自动备份我电脑上的文件.而且这个应用程序有一个启动参数-autostart",如果这个应用程序用这个参数运行,它会加载最新的设置(如果运行这个,诅咒没有这个参数的应用程序,它只会运行而不加载最新的设置.)

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.)

当我通过添加-autostart"参数为此应用程序创建快捷方式时,它运行良好并加载设置.但是我希望每次启动计算机时都能自动运行此应用程序,因此我在注册表中的 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] 中创建了一个运行键,该键值为"F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe" -autostart

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

但是我没有得到我想要的,它只是没有像在没有参数的情况下执行时那样加载设置.我什至将其归咎于值中双引号的位置,所以我尝试了该值"F:\Projects\AutoBackup\AutoBackup\bin\Debug\AutoBackup.exe -autostart" 和 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.

那么,如何正确地将参数传递给注册表中的应用程序?

推荐答案

参数前面必须有一个百分号 (%).

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

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

这篇关于如何在注册表运行键中为我的启动应用程序传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆