简体   繁体   English

尝试使用批处理文件在Windows中编辑注册表

[英]Trying to edit the registry in Windows with a batch file

I am supporting a few offices across the country running Windows XP. 我支持全国各地运行Windows XP的几个办事处。 They are stand alone, no Windows Server or Active Directory, anything like that. 它们是独立的,没有Windows Server或Active Directory,类似的东西。 I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Google Talk. 我刚刚将它们切换到Google Apps,并在此过程中将Windows Live Messenger替换为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. 我真的想阻止Windows Live被使用,该平台发送了大量垃圾邮件,似乎有很多漏洞。 I have tested making a registry edit to key 我已经测试过对密钥进行注册表编辑

HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun 

adding a string value msnmsgr.exe set to 1 . 添加字符串值msnmsgr.exe设置为1 I did it manually on one machine, and it worked, under both profiles, it wouldn't start Messenger. 我在一台机器上手动完成它,并且它在两个配置文件下工作,它不会启动Messenger。 After my success, I wrote a .REG file thusly: 在我成功之后,我写了一个.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. 它似乎写入注册表,但Live正在启动。 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. 似乎这可能是在Serverfault和这里之间的任何一种方式,但我去了这里,因为管理部分似乎已经解决,但涉及的小编程没有成功。

Thanks in advance for any assistance. 在此先感谢您的任何帮助。

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"). 根据kb文章 ,REG_SZ值应以数字命名,以“1”开头,包含的数据将是可执行文件名(“msnmsgr.exe”)。 Thus, your .REG file should look like this: 因此,您的.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.EXE program for simple edits like this, rather than importing a .REG file. 此外,我建议您使用REG.EXE程序进行简单的编辑,而不是导入.REG文件。 For the change you wanted, your REG.EXE command would look like this: 对于您想要的更改,您的REG.EXE命令将如下所示:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" /v "1" /t REG_SZ /d "msnmsgr.exe" /f

导出您手动添加的注册表项,并将.reg文件与通过regedit导入的文件进行比较。

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

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