|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『楼 主』:
[已结]如何用批处理分析注册表中收藏夹的路径?
使用 LLM 解释/回答一下
我发现许多Windows XP用户的收藏夹的路径并非默认的,而是经用户自己修改的。在备份收藏夹时常常是大费周折,后来我发现在注册表中可以找到收藏夹的路径。以下是我在一个用户注册表中手工导出的键值:
"Favorites"="D:\\!临时文件夹\\!互联网临时文件夹\\Favorites"
"Personal"="D:\\!我的文档"
"SendTo"="D:\\!我的文档\\SendTo"
"Favorites"="D:\\!临时文件夹\\!互联网临时文件夹\\Favorites"
"Personal"="D:\\!我的文档"
"SendTo"="D:\\!我的文档\\SendTo"
-------------------------------------------------------
我想通过批处理实现以下目的:
1、先用批处理自动导出用户注册表的和分支。并存为Favorites.reg文件。
2、然后,再用批处理对Favorites.reg文件进行处理,取得Favorites所在路径并保存到%fav%变量中备用。
请问批处理中如何能达到这个效果?,请各位朋友指点,在此先谢谢了!
Last edited by sglxy on 2006-11-3 at 08:11 AM ]
I find that the path of the favorites of many Windows XP users is not the default one, but modified by the users themselves. It is often very troublesome to back up the favorites. Later, I found that the path of the favorites can be found in the registry. The following is the key value I manually exported from a user's registry:
"Favorites"="D:\\!Temporary Folder\\!Internet Temporary Folder\\Favorites"
"Personal"="D:\\!My Documents"
"SendTo"="D:\\!My Documents\\SendTo"
"Favorites"="D:\\!Temporary Folder\\!Internet Temporary Folder\\Favorites"
"Personal"="D:\\!My Documents"
"SendTo"="D:\\!My Documents\\SendTo"
-------------------------------------------------------
I want to use a batch process to achieve the following purposes:
1. First, use the batch process to automatically export the and branches of the user's registry. And save it as the Favorites.reg file.
2. Then, use the batch process to process the Favorites.reg file, obtain the path where the Favorites is located and save it to the %fav% variable for subsequent use.
How can this effect be achieved in the batch process? Please friends give pointers, thank you in advance here!
Last edited by sglxy on 2006-11-3 at 08:11 AM ]
|
|
2006-10-31 09:37 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
晕,这么复杂啊~:)
我装有系统的分区里除了IE收藏夹(%HOMEPATH%\Favorites)备份以外,
桌面上使用的重要文档和常进的目录,全是以快捷方式指向非系统所在分区的某个目录而已,
系统坏了除了收藏夹要备份以外(RAR压缩收藏夹目录,也就一分钟),
然后没有再要备份的了,GHOST就完了~:)
(系统分区除了那个收藏夹以外,从来不放任何将来还要备份花时间的东东,这样省事)
Oh, it's so complicated~ : )
Except for backing up the IE favorites (%HOMEPATH%\Favorites) in the partition where the system is installed,
the important documents used on the desktop and the frequently accessed directories are all just shortcuts pointing to a directory in a non-system partition.
When the system is broken, besides backing up the favorites (RAR compresses the favorites directory, which only takes a minute),
there's nothing else to back up, just do GHOST~ : )
(Except for that favorites, the system partition never stores any things that need to be backed up and take time in the future, which is convenient)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-10-31 10:07 |
|
|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
我只想将其中的"Favorites"="D:\\!临时文件夹\\!互联网临时文件夹\\Favorites"
找出来改变为D:\!临时文件夹\!互联网临时文件夹\Favorites 并保存到%fav%变量中去。
I just want to find the part where "Favorites"="D:\\! Temporary Folder\\! Internet Temporary Folder\\Favorites" and change it to D:\! Temporary Folder\! Internet Temporary Folder\Favorites and save it to the %fav% variable.
|
|
2006-10-31 10:44 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
@ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=1,2,*" %%i in ('REG QUERY "HKCU\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\SHELL FOLDERS" ^| FIND /I "FAVORITES"') DO (
SET Fav_IN_SHELL_FAV=%%k
ECHO Favorites在SHELL FOLDERS子键下的值是:
ECHO !Fav_IN_SHELL_FAV!)
echo
for /f "tokens=1,2,*" %%i in ('REG QUERY "HKCU\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\USER SHELL FOLDERS" ^| FIND /I "FAVORITES"') DO (
SET Fav_USER_SHELL_FAV=%%k
ECHO Favorites在USER SHELL FOLDERS子键下的值是:
ECHO !Fav_USER_SHELL_FAV!)
PAUSE
@ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=1,2,*" %%i in ('REG QUERY "HKCU\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\SHELL FOLDERS" ^| FIND /I "FAVORITES"') DO (
SET Fav_IN_SHELL_FAV=%%k
ECHO The value of Favorites under the SHELL FOLDERS subkey is:
ECHO !Fav_IN_SHELL_FAV!)
echo
for /f "tokens=1,2,*" %%i in ('REG QUERY "HKCU\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\USER SHELL FOLDERS" ^| FIND /I "FAVORITES"') DO (
SET Fav_USER_SHELL_FAV=%%k
ECHO The value of Favorites under the USER SHELL FOLDERS subkey is:
ECHO !Fav_USER_SHELL_FAV!)
PAUSE
|
|
2006-10-31 12:22 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites"') do (
set Fav=%%j
)
echo 当前收藏夹位于 %Fav%
pause
Last edited by fastslz on 2006-10-31 at 12:52 PM ]
```
@echo off
for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites"') do (
set Fav=%%j
)
echo The current favorites are located at %Fav%
pause
```
Last edited by fastslz on 2006-10-31 at 12:52 PM ]
|

第一高手 第二高手
我的小站
 |
|
2006-10-31 12:37 |
|
|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
两位朋友的方法都很精练,但是得到的值却并非我所希望的D:\!临时文件夹\!互联网临时文件夹\Favorites。而是好象短路径的那种:当前收藏夹位于 D:\互联网临时文?
Both friends' methods are very concise, but the value obtained is not the D:\!Temporary Folder\!Internet Temporary Folder\Favorites I hoped for. Instead, it seems like the short path: The current favorite is located in D:\Internet Temporary Document?
|
|
2006-10-31 19:09 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
其实用鼠标直接去剪切到后面的盘就行了,剪好了做下备份就一直认后面的盘了。
Actually, you can directly use the mouse to cut to the subsequent disk. After cutting, make a backup and then it will always recognize the subsequent disk.
|
|
2006-10-31 20:27 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
好象短路径的那种?中文长文件名我未测试~
Seems like the short path kind? I haven't tested the Chinese long file name yet~
|

第一高手 第二高手
我的小站
 |
|
2006-10-31 21:05 |
|
|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by NaturalJ0 at 2006-10-31 08:27 PM:
其实用鼠标直接去剪切到后面的盘就行了,剪好了做下备份就一直认后面的盘了。
谢谢NaturalJ0的热心解答,之所以需要批处理的方式自动分析,是希望它成为某一批处理的其中一个模块。在系统维护中大大减轻操作者的劳动强度。而用鼠标就失去了意义。
另外,本人在4、5楼朋友的启发下。将其作品改写如下,请朋友们指正:
@echo off
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" fav.reg
for /f "tokens=2 delims==" %%b in ('find /i "Favorites" fav.reg') do set fav=%%b
set fav=%fav:\\=\%
set fav=%fav:"=%
echo 本机的收藏夹位于%fav%>收藏夹.txt
del fav.reg
pause>nul
但是本批处理脚本运行结束后,总一个提示“操作成功结束”。该如何去掉它?
Last edited by sglxy on 2006-10-31 at 09:26 PM ]
Originally posted by NaturalJ0 at 2006-10-31 08:27 PM:
Actually, you can directly use the mouse to cut to the subsequent drive. After cutting, make a backup and then it will always recognize the subsequent drive.
Thanks to NaturalJ0 for the enthusiastic answer. The reason why a batch processing method is needed for automatic analysis is to make it one of the modules of a certain batch processing, which can greatly reduce the labor intensity of the operator in system maintenance. Using the mouse would lose the meaning.
In addition, inspired by the friends on floors 4 and 5, I rewrote my work as follows. Please friends give your comments:
@echo off
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" fav.reg
for /f "tokens=2 delims==" %%b in ('find /i "Favorites" fav.reg') do set fav=%%b
set fav=%fav:\\=\%
set fav=%fav:"=%
echo The favorite folder of this computer is located at %fav%>收藏夹.txt
del fav.reg
pause>nul
But after the execution of this batch script ends, there is always a prompt "Operation completed successfully". How to remove it?
Last edited by sglxy on 2006-10-31 at 09:26 PM ]
|
|
2006-10-31 21:18 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
@echo off
REG EXPORT "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" a.reg /nt4>nul
for /f "tokens=2 delims==" %%a in ('find "Favorites" a.reg') do set fav=%%~a
echo 收藏夹位于%fav%
```
@echo off
REG EXPORT "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" a.reg /nt4>nul
for /f "tokens=2 delims==" %%a in ('find "Favorites" a.reg') do set fav=%%~a
echo The favorite folder is located at %fav%
```
|

我的网络U盘 我的网络第2个U盘
论坛软件下载链接
灵雨飘零论坛
论坛新手必读,所有人的基本行为准则
刷QQ空间人气、留言的小软件 |
|
2006-10-31 22:04 |
|
|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by qwe1234567 at 2006-10-31 10:04 PM:
@echo off
REG EXPORT "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" a.reg /nt4>nul
for /f "tokens=2 delims==" %%a in ('find "Favorites&q ...
谢谢qwe1234567版主,我明白了,原来这句提示是reg命令产生的,我开始以为是del fav.reg产生的。
Thanks to the moderator qwe1234567, I understand. Originally, this prompt was generated by the reg command. I initially thought it was generated by del fav.reg.
|
|
2006-10-31 22:36 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
想不到 reg export 还有一个隐藏的参数,呵呵,学习了。
Unexpectedly, reg export has a hidden parameter, heh, learned it.
|
|
2006-11-1 00:23 |
|
|
sglxy
中级用户
   MS-DOS爱好者
积分 397
发帖 87
注册 2002-12-15
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
请问超级版主,REG EXPORT "HKCU\Software\……一句中的“/nt4”参数代表什么意思?
另外,你的帖子里有一句:set fav=%%~a 我知道是附值。 但是其中的
“%%a”为何写成“%%~a”,它的意义是什么?请指点一下。
Last edited by sglxy on 2006-11-1 at 12:54 AM ]
May I ask the super moderator, what does the "/nt4" parameter in the sentence REG EXPORT "HKCU\Software\…… mean?
In addition, there is a sentence in your post: set fav=%%~a. I know it's assignment. But why is "%%a" written as "%%~a", what is its meaning? Please give me some guidance.
Last edited by sglxy on 2006-11-1 at 12:54 AM ]
|
|
2006-11-1 00:51 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
"/nt4"参数是指定导出的注册表文件里面表明的注册表版本信息,也就是"REGEDIT4"了,没有"/nt4"的参数,那么版本就可能是"Windows Registry Editor Version 5.00"了。
"%%~a"是"%%a"变量的扩展,作用就是去掉"%%a"外面的引号。
The "/nt4" parameter specifies the registry version information indicated in the exported registry file, which is "REGEDIT4". Without the "/nt4" parameter, the version may be "Windows Registry Editor Version 5.00".
"%%~a" is an expansion of the "%%a" variable, and its function is to remove the quotes outside "%%a".
|
|
2006-11-1 01:39 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
代超版回答:%%~a 是删除字符串前后的任何引号的意思。
Deputy version answers: %%~a means to remove any quotes before and after the string.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-1 01:41 |
|