China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-12 19:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to add registry key values using batch processing? View 2,070 Replies 18
Original Poster Posted 2007-06-26 01:10 ·  中国 广东 广州 鹏博士宽带
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
Just want to modify [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders] The desktop inside is changed to d:\123, which was originally %...% desktop.

I tried the following:
@Echo off
regedit /s regfile.reg
taskkill /im explorer.exe /f
explorer.exe
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
exit

Do I need to have a reg file first to use regedit /s to import and then add? Can I directly use one bat to add the registry key value?

Can running taskkill /im explorer.exe /f not make the taskbar disappear and also refresh the desktop?

Why does the dos window not close at the end of my bat?

It would be better if it can be realized with vbs!
Floor 2 Posted 2007-06-26 02:52 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Modifying the registry can use the reg command.
Floor 3 Posted 2007-06-26 08:56 ·  中国 广东 东莞 电信
新手上路
Credits 16
Posts 7
Joined 2007-06-25 08:30
19-year member
UID 92274
Gender Male
Status Offline
Using the REG ADD command can do~~~~


Windows Console Registry Tool - Copyright (C) Microsoft Corp. 1981-2001. All rights reserved.REG ADD KeyName

KeyName FullKey
Machine name of a remote machine - ignored defaults to current machine.
Only HKLM and HKU on remote machines.
FullKey ROOTKEY\SubKey
ROOTKEY
SubKey The full name of the registry key under the selected ROOTKEY

/v The name of the value to add under the specified key

/ve Adds a blank value name <No Name> to the registry key

/t RegKey data type



If omitted, REG_SZ is used

/s Specifies a character to use as a separator in REG_MULTI_SZ data strings
If omitted, "\0" is used as the separator

/d The data to assign to the added registry ValueName

/f Forcefully overwrite an existing registry key without prompting

For example:

REG ADD \\ABC\HKLM\Software\MyCo
Adds a registry key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Adds a value (name: Data, type: REG_BINARY, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
Adds a value (name: MRU, type: REG_MUTLI_SZ, data: fax\0


[ Last edited by recooliu on 2007-6-26 at 09:04 AM ]
QQ增值服务---8元/月/项
可查时间
可续费
不加好友
Floor 4 Posted 2007-06-26 09:29 ·  中国 四川 雅安 电信
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
The complexity upstairs is too high. Can you be more specific?
Floor 5 Posted 2007-06-26 10:47 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Add a boot - up self - starting item

@echo off
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v MyAutoRun /t REG_SZ /d C:/test.bat /f
Floor 6 Posted 2007-06-26 10:51 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Specific to your question

@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop /t REG_EXPAND_SZ /d d:\123 /f
Floor 7 Posted 2007-06-26 18:52 ·  中国 广东 广州 鹏博士宽带
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
Do you mean I have to add them one by one to the machines in the internet café?
Floor 8 Posted 2007-06-26 19:09 ·  中国 江苏 常州 武进区 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
For /f "delims=" %%i in (Remote Machine.txt) do (
REG ADD \\%%i\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop /t REG_EXPAND_SZ /d d:\123 /f
)

Unable to test :(
Floor 9 Posted 2007-06-26 19:11 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
//The machines in the internet café, do you want me to add them one by one??

Not making it clear on the first floor, do you want everyone to guess one by one??
^_^
Floor 10 Posted 2007-06-26 20:21 ·  中国 广东 广州 鹏博士宽带
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
What about the last two questions?

[ Last edited by coolclack on 2007-6-26 at 08:24 PM ]
Floor 11 Posted 2007-06-26 20:30 ·  中国 广东 广州 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
Can running taskkill /im explorer.exe /f prevent the taskbar from disappearing and still refresh the desktop?

No.

Why does the DOS window not close at the end of my bat?

When directly calling other commands, it will wait for the end of other commands before proceeding to the next command.

@Echo off
regedit /s regfile.reg
taskkill /im explorer.exe /f
start "" explorer.exe
start "" RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
exit
正在潜水修练的批处理小白
Floor 12 Posted 2007-06-26 20:33 ·  中国 广东 广州 鹏博士宽带
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop /t REG_EXPAND_SZ /d D:\123 /f
taskkill /im explorer.exe /f
start "" explorer.exe
start "" RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
exit

Is it okay now?? Upstairs?!
Floor 13 Posted 2007-06-26 20:37 ·  中国 广东 广州 鹏博士宽带
新手上路
Credits 18
Posts 8
Joined 2007-06-24 11:29
19-year member
UID 92223
Gender Male
Status Offline
@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop /t REG_EXPAND_SZ /d C:\Documents and settings\Administrator\桌面 /f
taskkill /im explorer.exe /f
start "" explorer.exe
start "" RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
exit



Oh! Can't brush back to the original desktop
What is too many command line parameters?
Floor 14 Posted 2007-06-26 22:09 ·  中国 广东 深圳 电信
初级用户
Credits 52
Posts 24
Joined 2007-05-09 14:26
19-year member
UID 87949
Gender Male
Status Offline
Refreshing the desktop might as well use the following command...


ntsd -c q -pn explorer.exe
Floor 15 Posted 2007-06-26 22:19 ·  中国 江苏 常州 武进区 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Try VBS:
path="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\"
set ws=wscript.createobject("wscript.shell")
t=ws.regwrite(path & "Desktop","D:\123")
ws.run "ntsd -c q -pn explorer.exe"

[ Last edited by terse on 2007-6-27 at 11:58 PM ]
Forum Jump: