![]() |
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-10 18:02 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Solved] How to use batch processing to analyze the path of favorites in the registry? |
| Printable Version 4,333 / 19 |
| Floor1 sglxy | Posted 2006-10-31 09:37 |
| 中级用户 Posts 87 Credits 397 | |
|
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 ] |
|
| Floor2 redtek | Posted 2006-10-31 10:07 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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) |
|
| Floor3 sglxy | Posted 2006-10-31 10:44 |
| 中级用户 Posts 87 Credits 397 | |
|
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.
|
|
| Floor4 lxmxn | Posted 2006-10-31 12:22 |
| 版主 Posts 4,938 Credits 11,386 | |
|
|
|
| Floor5 fastslz | Posted 2006-10-31 12:37 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
```
@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 ] |
|
| Floor6 sglxy | Posted 2006-10-31 19:09 |
| 中级用户 Posts 87 Credits 397 | |
|
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?
|
|
| Floor7 NaturalJ0 | Posted 2006-10-31 20:27 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
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.
|
|
| Floor8 fastslz | Posted 2006-10-31 21:05 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
Seems like the short path kind? I haven't tested the Chinese long file name yet~
|
|
| Floor9 sglxy | Posted 2006-10-31 21:18 |
| 中级用户 Posts 87 Credits 397 | |
Originally posted by NaturalJ0 at 2006-10-31 08:27 PM: 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 ] |
|
| Floor10 不得不爱 | Posted 2006-10-31 22:04 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
```
@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% ``` |
|
| Floor11 sglxy | Posted 2006-10-31 22:36 |
| 中级用户 Posts 87 Credits 397 | |
|
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.
|
|
| Floor12 lxmxn | Posted 2006-11-01 00:23 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Unexpectedly, reg export has a hidden parameter, heh, learned it. |
|
| Floor13 sglxy | Posted 2006-11-01 00:51 |
| 中级用户 Posts 87 Credits 397 | |
|
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 ] |
|
| Floor14 lxmxn | Posted 2006-11-01 01:39 |
| 版主 Posts 4,938 Credits 11,386 | |
|
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". |
|
| Floor15 namejm | Posted 2006-11-01 01:41 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Deputy version answers: %%~a means to remove any quotes before and after the string.
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |