尝试使用批处理文件在 Windows 中编辑注册表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3961790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trying to edit the registry in Windows with a batch file
提问by Kevin
I am supporting a few offices across the country running Windows XP. They are stand alone, no Windows Server or Active Directory, anything like that. I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Google Talk. I really want to stop Windows Live from being used, the platform sends so much spam and seems to have a lot of holes. I have tested making a registry edit to key
我正在为全国各地运行 Windows XP 的几个办事处提供支持。它们是独立的,没有 Windows Server 或 Active Directory 之类的东西。我只是将它们切换到 Google Apps,并在此过程中用 Google Talk 替换了 Windows Live Messenger。我真的很想停止使用Windows Live,该平台发送了如此多的垃圾邮件,并且似乎有很多漏洞。我已经测试过对注册表项进行编辑
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun
adding a string value msnmsgr.exe
set to 1
. I did it manually on one machine, and it worked, under both profiles, it wouldn't start Messenger. After my success, I wrote a .REG file thusly:
添加一个字符串值msnmsgr.exe
设置为1
. 我在一台机器上手动完成了它,它在两种配置文件下都有效,它不会启动 Messenger。成功后,我写了一个 .REG 文件:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun]
"msnmsgr.exe"="1"
And a batch file, run from the same directory, written like this:
还有一个批处理文件,从同一个目录运行,写成这样:
@ECHO off
REGEDIT.EXE /S msn.reg
It seems to write to the registry, but Live is starting. No idea what's happening. Seems this could have gone either way between Serverfault and here, but I went here since the Administration part seems resolved yet the little programming involved isn't working out.
它似乎写入注册表,但 Live 正在启动。不知道发生了什么。似乎这在 Serverfault 和这里之间可能有任何一种方式,但我去了这里,因为管理部分似乎已解决,但所涉及的小编程并没有奏效。
Thanks in advance for any assistance.
在此先感谢您的帮助。
回答by ewall
Looks to me like you have the Registry value name and data swapped. According to the kb article, the REG_SZ value(s) should be named numerically starting with "1", and the included data would be the executable name ("msnmsgr.exe"). Thus, your .REG file should look like this:
在我看来,您已经交换了注册表值名称和数据。根据kb 文章,REG_SZ 值应以数字方式命名,以“1”开头,包含的数据将是可执行文件名称(“msnmsgr.exe”)。因此,您的 .REG 文件应如下所示:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun]
"1"="msnmsgr.exe"
Also, I would recommend that you use the REG.EXEprogram for simple edits like this, rather than importing a .REG file. For the change you wanted, your REG.EXE command would look like this:
此外,我建议您使用REG.EXE程序进行这样的简单编辑,而不是导入 .REG 文件。对于您想要的更改,您的 REG.EXE 命令将如下所示:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" /v "1" /t REG_SZ /d "msnmsgr.exe" /f
回答by Michael Goldshteyn
Export the registry key that you manually added and compare the .reg file to the one you imported via regedit.
导出您手动添加的注册表项,并将 .reg 文件与您通过 regedit 导入的文件进行比较。