中国DOS联盟论坛

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-09-25 12:13
47,813 topics / 349,918 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » How to add registry key values using batch processing?
Printable Version  2,447 / 18
Floor1 coolclack Posted 2007-06-26 01:10
新手上路 Posts 8 Credits 18
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!
Floor2 lxmxn Posted 2007-06-26 02:52
版主 Posts 4,938 Credits 11,386
Modifying the registry can use the reg command.
Floor3 recooliu Posted 2007-06-26 08:56
新手上路 Posts 7 Credits 16
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 ]
Floor4 coolclack Posted 2007-06-26 09:29
新手上路 Posts 8 Credits 18
The complexity upstairs is too high. Can you be more specific?
Floor5 HAT Posted 2007-06-26 10:47
版主 Posts 5,017 Credits 9,023
Add a boot - up self - starting item
Floor6 HAT Posted 2007-06-26 10:51
版主 Posts 5,017 Credits 9,023
Specific to your question
Floor7 coolclack Posted 2007-06-26 18:52
新手上路 Posts 8 Credits 18
Do you mean I have to add them one by one to the machines in the internet café?
Floor8 terse Posted 2007-06-26 19:09
银牌会员 Posts 946 Credits 2,404
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 :(
Floor9 HAT Posted 2007-06-26 19:11
版主 Posts 5,017 Credits 9,023
//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??
^_^
Floor10 coolclack Posted 2007-06-26 20:21
新手上路 Posts 8 Credits 18
What about the last two questions?

[ Last edited by coolclack on 2007-6-26 at 08:24 PM ]
Floor11 dikex Posted 2007-06-26 20:30
高级用户 Posts 366 Credits 788
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
Floor12 coolclack Posted 2007-06-26 20:33
新手上路 Posts 8 Credits 18
@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?!
Floor13 coolclack Posted 2007-06-26 20:37
新手上路 Posts 8 Credits 18
@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?
Floor14 lasting Posted 2007-06-26 22:09
初级用户 Posts 24 Credits 52
Refreshing the desktop might as well use the following command...


ntsd -c q -pn explorer.exe
Floor15 terse Posted 2007-06-26 22:19
银牌会员 Posts 946 Credits 2,404
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 ]
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023