|
ken0212
初级用户
 
积分 24
发帖 8
注册 2006-4-10
状态 离线
|
『楼 主』:
关于用批处理命令修改注册表!!
使用 LLM 解释/回答一下
今天遇到一个问题就是用批处理命令修改注册表时遇到不懂的问题!以下是我编写的代码:
@echo off
echo Windows Registry Editor Version 5.00>>ok.reg
echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]>>ok.reg
echo "key"="C:\\WINDOWS\\key.exe">>ok.reg
regedit /s ok.reg
del ok.reg
不知道有没有错的!这是REG文件里的代码:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"key"="C:\\WINDOWS\\key.exe"
不明白是我在编写其他的注册项的时候就可以导入.但是有几个我怎么编也导不进去.我反复修改了N次了.应该没有问题了啊.我真的搞不清楚了.是不是命令用错了.麻烦高手指点一下.我都快疯了~~~如果可能的话加我QQ:50594677和我详细说一下!!
Today I encountered a problem when using batch commands to modify the registry and had some questions! Here is the code I wrote:
@echo off
echo Windows Registry Editor Version 5.00>>ok.reg
echo >>ok.reg
echo "key"="C:\\WINDOWS\\key.exe">>ok.reg
regedit /s ok.reg
del ok.reg
I don't know if there are any mistakes! This is the code in the REG file:
Windows Registry Editor Version 5.00
"key"="C:\\WINDOWS\\key.exe"
I don't understand that I can import it when I write other registry entries. But there are a few that I can't import no matter how I edit them. I have modified them many times repeatedly. It should be fine. I really can't figure it out. Is the command used incorrectly? Please ask an expert for guidance. I'm almost going crazy~~~ If possible, add my QQ: 50594677 and talk to me in detail!
|
|
2006-4-10 23:48 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
代码应该是没有错误的。
把不能导入的代码贴出来,大家帮你看看,加QQ就免了。
The code should be error-free. Post the code that can't be imported, and everyone will help you take a look. Just forget about adding QQ.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-4-11 09:02 |
|
|
ken0212
初级用户
 
积分 24
发帖 8
注册 2006-4-10
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
就是上面的代码不能导入啊..不然你们在自己的机上试试.
It's just that the code above can't be imported.. Otherwise you can try it on your own machine.
|
|
2006-4-11 11:32 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
使用REG工具不是更好
Using the REG tool is not better
|

http://www.msfans.net/bbs/ |
|
2006-4-11 11:54 |
|
|
kcdsw
中级用户
  
积分 404
发帖 179
注册 2006-3-30
状态 离线
|
|
2006-4-11 12:22 |
|
|
kcdsw
中级用户
  
积分 404
发帖 179
注册 2006-3-30
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
另外路径是\ 不要用\\
这个我也改过的
Also, the path is \, don't use \\. I also changed this.
|
|
2006-4-11 12:23 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
TO 楼上:
在XP中已经不需要空行了,而且开头的Windows Registry Editor Version 5.00也可以用REGEDIT4来代替。另外路径中的\也要在前面加个\来转义。
Re 楼主:
个人认为代码是没有错的,而且根据你的描述:
“不明白是我在编写其他的注册项的时候就可以导入.但是有几个我怎么编也导不进去.我反复修改了N次了.应该没有问题了啊.”
初步认为,由于run键的特殊性,可能开启了杀毒软件的注册表监控,导致一经修改又被恢复,所以建议先关闭杀毒软件以及其他监视类软件再修改。另外也许有权限的可能在里面,不过只要没有特别设置,对于HKEY_CURRENT_USER下的键应该是可以更改的。个人认为楼主应该从这几方面着手去检查。
TO the person above:
In XP, blank lines are no longer needed, and the initial "Windows Registry Editor Version 5.00" can also be replaced with REGEDIT4. Also, the \ in the path should be escaped by adding an extra \ in front.
Re the original poster:
Personally, I think the code is correct, and based on your description:
"I don't understand that I can import when I was writing other registry entries. But there are a few that I just can't import no matter how I edit them. I've modified them many times repeatedly. It should be no problem."
Preliminarily, it is considered that due to the particularity of the run key, the registry monitoring of the antivirus software may have been enabled, causing it to be restored as soon as it is modified. So it is suggested to first close the antivirus software and other monitoring software and then make the modification. Also, there may be an issue with permissions, but as long as there are no special settings, the keys under HKEY_CURRENT_USER should be changeable. Personally, I think the original poster should check from these aspects.
|
|
2006-4-11 13:03 |
|
|
xuantian
高级用户
   
积分 587
发帖 282
注册 2006-4-10
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
建议用reg命令,这样可以支持变量的录入
例如:
下面是拼音加加优盘版的部分批处理命令
reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v %SystemRoot%\system32\pyjj4.ime /t REG_SZ /d WINXPSP2 /f //Vista系统修正
set /p usbjj= 请输入当前路径后回车 //优盘加加路径
reg add "HKLM\SOFTWARE\jj4" /v "install path" /t REG_SZ /d "%usbjj%" /f //优盘加加路径
%SystemRoot% 会替换为windows的安装路径
%usbjj% 会替换为键盘输入的字符
Last edited by xuantian on 2006-4-11 at 16:05 ]
It is suggested to use the reg command, so that the entry of variables can be supported.
For example:
The following are some batch commands of Pinyin JiaJia USB version
reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v %SystemRoot%\system32\pyjj4.ime /t REG_SZ /d WINXPSP2 /f //Vista system correction
set /p usbjj= Please enter the current path and press Enter //USB JiaJia path
reg add "HKLM\SOFTWARE\jj4" /v "install path" /t REG_SZ /d "%usbjj%" /f //USB JiaJia path
%SystemRoot% will be replaced with the installation path of Windows
%usbjj% will be replaced with the characters entered by the keyboard
Last edited by xuantian on 2006-4-11 at 16:05 ]
|
|
2006-4-11 15:58 |
|
|
ken0212
初级用户
 
积分 24
发帖 8
注册 2006-4-10
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
回复7楼:
你说的两种方法我都试过了.都是以失败告终.真的很郁闷.也不知道出现什么错误.7楼大哥你也可以自己试验一下.帮忙找一下是什么问题!也很希望高手来解答一下..~~
回复8楼:
我曾经看来有人用过setlocal命令和reg add 命令来修改注册表.以下是我看到的代码:
@echo off
setlocal
set regkey="HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Licensing Core"
reg add %regkey% /v EnableConcurrentSessions /T REG_DWORD /D 1 /f
endlocal
由于本人不太熟悉这两个命令.请高手给我讲解一下~~~谢谢了.
Reply to post 7:
The two methods you mentioned, I've tried both. Both ended in failure. Really depressed. I don't know what error occurred. Brother post 7, you can also test it yourself. Help find out what the problem is! Also, I really hope experts can give an answer..~~
Reply to post 8:
I once saw someone use the setlocal command and the reg add command to modify the registry. The following is the code I saw:
@echo off
setlocal
set regkey="HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Licensing Core"
reg add %regkey% /v EnableConcurrentSessions /T REG_DWORD /D 1 /f
endlocal
Since I'm not very familiar with these two commands, please experts explain to me~~~ Thank you.
|
|
2006-4-11 21:02 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
用你的代码测试成功,当前用户只具有users组的权限,未开启杀毒软件(其实是没装过)。
代码看来是可行的,不知道你是怎么测试的。
你可以先手工在run键下添加一键试试。
The code has been tested successfully. The current user only has the permissions of the users group, and the antivirus software is not enabled (actually, it has never been installed). The code seems to be feasible. I don't know how you tested it. You can first manually add a one-click under the run key and try.
|
|
2006-4-11 21:14 |
|
|
ken0212
初级用户
 
积分 24
发帖 8
注册 2006-4-10
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
我生成批处理文件后就直接双击运行了啊..我的用户是管理员的权限呢..应该不是这个问题吧.我也不知道是什么问题.但是我用reg add 命令就可以加进去.还有就是用reg add 命令时.有时候会出现参数太多的错误.请问一下这是什么错误.应该如何解决!!!
I generated the batch file and just double-clicked to run it. My user has administrator privileges. It shouldn't be this problem. I don't know what the problem is. But I can use the reg add command to add it in. Also, when using the reg add command, sometimes there is an error of too many parameters. What is this error and how to solve it!!!
|
|
2006-4-11 21:41 |
|
|
xuantian
高级用户
   
积分 587
发帖 282
注册 2006-4-10
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
在使用 reg 命令时将添加的键和键值用引号引起来,这样之间有空格时才不会出错.
至于命令,可以使用帮助,都是中文的
比如: 添加注册项可用 reg add /? 来获取帮助等等....
When using the reg command, enclose the added key and key value in quotes, so that there will be no errors when there are spaces in between. As for the commands, you can use the help, which are all in Chinese. For example: You can use reg add /? to get help when adding registry entries, etc....
|
|
2006-4-11 23:25 |
|
|
ken0212
初级用户
 
积分 24
发帖 8
注册 2006-4-10
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
谢谢12楼.问题已经解决了..
Thanks to the 12th floor. The problem has been solved..
|
|
2006-4-12 15:35 |
|
|
xuantian
高级用户
   
积分 587
发帖 282
注册 2006-4-10
状态 离线
|
『第 14 楼』:
用批处理命令操作注册表的误区
使用 LLM 解释/回答一下
Windows Registry Editor Version 5.00>>aaa.reg
用上面的命令来建立注册表临时文件,并通过它来间接操作注册表是不正确的方法.
原因是:
通过这样操作保存的临时文件是超文本格式, 但 Windows Registry Editor Version 5.00 注册表却是(UniCode)双字节文本,NT的注册表一旦检测到注册表文件中的第一行为 Windows Registry Editor Version 5.00 时,就会将它最为二进制的NT注册表文件,理所当然的, 这个注册表文本也就被NT的注册表当作UniCode文本来出来了.
一般来说,如果在此时,注册表项和值中没有空格时,应该是可以正常导入的,但如果其中一项或一值中有空格时,注册表的识别就会出错,比如"Windows NT".
所以正确的写法应该是 REGEDIT4>>aaa.reg
这样建立文件才会被NT的注册表当作纯文本格式的注册表文件(即Win9X系列的注册表文件格式),也就不会再出错了.
Windows Registry Editor Version 5.00>>aaa.reg 的写法是混淆了注册表的格式感念! 所以有时会出错也就不奇怪了
暂时就写到这里吧, 想到后再继续:D
Windows Registry Editor Version 5.00>>aaa.reg
Using the above command to create a registry temporary file and indirectly operate the registry through it is an incorrect method.
The reason is:
The temporary file saved through such an operation is in hypertext format, but the Windows Registry Editor Version 5.00 registry is (UniCode) double-byte text. Once NT's registry detects that the first line of the registry file is Windows Registry Editor Version 5.00, it will treat it as a binary NT registry file. Naturally, this registry text is also treated as UniCode text by NT's registry.
Generally speaking, if there are no spaces in the registry keys and values at this time, it should be able to be imported normally, but if there is a space in one of the keys or values, the registry's identification will go wrong, such as "Windows NT".
So the correct writing should be REGEDIT4>>aaa.reg
In this way, the created file will be regarded by NT's registry as a pure text format registry file (that is, the registry file format of the Win9X series), and there will be no more errors.
The writing of Windows Registry Editor Version 5.00>>aaa.reg confuses the concept of registry format! So it is not surprising that sometimes errors occur
That's all for now. I'll continue when I think of it :D
|
|
2006-4-12 16:35 |
|
|
JonePeng
金牌会员
      D◎$ Fαп
积分 4562
发帖 1883
注册 2004-1-19 来自 广东广州
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
嗯。NT平台的系统都是以 Unicode 来编码,而且这些系统都向下兼容 DOS/Win9x 用的 ANSI 编码。
NT系统下的“记事本”,其保存类型选项中就有几种文本类型。相比之下,Win9x的“记事本”真的逊色很多!
Um. NT platform systems are all encoded in Unicode, and these systems are downwardly compatible with the ANSI encoding used by DOS/Win9x.
In the "Notepad" under NT systems, there are several text type options in the save type. In contrast, the "Notepad" of Win9x is really much less capable!
|

----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
|
|
2006-4-12 21:00 |
|