【问题标题】:Add start up reg key without run the program添加启动 reg 密钥而不运行程序
【发布时间】:2016-03-28 08:47:59
【问题描述】:

我编写了一个程序,它在 windows 启动时启动。我的代码是这样的:

public partial class Form1 : Form
    {
        RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);//kanei autostart to programma sto anoigma tou upologisti
        public Form1()
        {
            reg.SetValue("Computer Integrity", Application.ExecutablePath.ToString());//computer integrity is the reg key name
            reg.Close();
            InitializeComponent();
        }

现在的问题是,为了启动程序,在 windows 启动时,需要先打开它,这样密钥才会在“注册表编辑器”中注册。有没有办法创建一个文件(例如.bat)以便将此密钥注册到“注册表编辑器”,而无需打开程序??

【问题讨论】:

    标签: registrykey


    【解决方案1】:

    您可以在 regisgry 中手动创建密钥,然后导出到 yourfile.reg 文件: https://technet.microsoft.com/en-us/library/cc755091.aspx 然后您可以从命令行运行 regedit:

    regedit.exe /S yourfile.reg
    

    您也可以通过 REG ADD 命令直接从批处理文件运行这样的命令。 详情参考这里:Run reg command in cmd (bat file)?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-11
      • 2011-02-11
      • 2013-01-23
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 2012-05-07
      • 2013-09-29
      相关资源
      最近更新 更多