![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-01 23:14 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » About modifying the registry with batch commands! |
| Printable Version 3,515 / 19 |
| Floor1 ken0212 | Posted 2006-04-10 23:48 |
| 初级用户 Posts 8 Credits 24 | |
|
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 [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 I don't know if there are any mistakes! This is the code in the REG file: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] "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! |
|
| Floor2 Climbing | Posted 2006-04-11 09:02 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
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.
|
|
| Floor3 ken0212 | Posted 2006-04-11 11:32 |
| 初级用户 Posts 8 Credits 24 | |
|
It's just that the code above can't be imported.. Otherwise you can try it on your own machine.
|
|
| Floor4 chenhui530 | Posted 2006-04-11 11:54 |
| 高级用户 Posts 273 Credits 772 | |
|
Using the REG tool is not better
|
|
| Floor5 kcdsw | Posted 2006-04-11 12:22 |
| 中级用户 Posts 179 Credits 404 | |
|
Hehe blank line
Are you blank? |
|
| Floor6 kcdsw | Posted 2006-04-11 12:23 |
| 中级用户 Posts 179 Credits 404 | |
|
Also, the path is \, don't use \\. I also changed this.
|
|
| Floor7 3742668 | Posted 2006-04-11 13:03 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
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. |
|
| Floor8 xuantian | Posted 2006-04-11 15:58 |
| 高级用户 Posts 282 Credits 587 | |
|
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 ] |
|
| Floor9 ken0212 | Posted 2006-04-11 21:02 |
| 初级用户 Posts 8 Credits 24 | |
|
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. |
|
| Floor10 3742668 | Posted 2006-04-11 21:14 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
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.
|
|
| Floor11 ken0212 | Posted 2006-04-11 21:41 |
| 初级用户 Posts 8 Credits 24 | |
|
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!!!
|
|
| Floor12 xuantian | Posted 2006-04-11 23:25 |
| 高级用户 Posts 282 Credits 587 | |
|
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....
|
|
| Floor13 ken0212 | Posted 2006-04-12 15:35 |
| 初级用户 Posts 8 Credits 24 | |
|
Thanks to the 12th floor. The problem has been solved..
|
|
| Floor14 xuantian | Posted 2006-04-12 16:35 |
| 高级用户 Posts 282 Credits 587 | |
|
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 |
|
| Floor15 JonePeng | Posted 2006-04-12 21:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
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! |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |