简体   繁体   English

C#注册表导入

[英]C# Registry Import

I am trying to import a registry value that was saved previously thru C#. 我正在尝试导入以前通过C#保存的注册表值。 Regedit runs each time I import, but the value doesnt change. 每次导入时,Regedit都会运行,但是值不会更改。 The only difference I get when running as administrator or not is the UAC prompt for regedit when not elevated. 无论是否以管理员身份运行,我得到的唯一区别是未提升时,UAC提示输入regedit。 Regedit still seems to run, but it seems to not be reading and importing the .reg file. Regedit似乎仍在运行,但似乎没有读取和导入.reg文件。

  Import:
        {

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {

                string FullPath = openFileDialog1.FileName;

                MessageBox.Show(Convert.ToString(FullPath));

                Process regeditProcess = Process.Start("regedit.exe", "/s" + FullPath);
                regeditProcess.WaitForExit();
            }



            return;
        }

Problem could be if FullPath have spaces in it. 问题可能是FullPath是否包含空格。 Instead of: 代替:

Process regeditProcess = Process.Start("regedit.exe", "/s" + FullPath);

try this: 尝试这个:

Process regeditProcess = Process.Start("regedit.exe", "/s \"" + FullPath + "\"");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM