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-08-02 08:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Help! About the desktop variables in XP, creating shortcuts on the desktop. View 1,520 Replies 6
Original Poster Posted 2006-10-19 09:57 ·  中国 山东 青岛 李沧区 联通
初级用户
Credits 140
Posts 8
Joined 2004-08-18 00:00
21-year member
UID 30357
Gender Male
Status Offline
Want to make a batch script that automatically adds shortcuts to the desktop. The Chinese version's desktop is "桌面", and the Korean version is "바탕 화면". Well, just use "desktop" for both. Hate Microsoft. Now the idea is like this. In the registry, under HKLM\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046}, there is the name of the desktop. Then do reg EXport HKLM\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046} TEMP.REG, REN TEMP.REG TEMP_BAK.REG, TYPE TEMP_BAK.REG >TEMP.TXT, DEL TEMP_BAK.REG. The content of TEMP.TXT is:

Windows Registry Editor Version 5.00


@="桌面"


@="shell32.dll"
"ThreadingModel"="Apartment"
And so on. How to get the text inside the two quotes of @="桌面" into a variable. Please help everyone!

[ Last edited by namejm on 2006-10-22 at 06:46 ]
Floor 2 Posted 2006-10-19 11:03 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

@ECHO OFF
FOR /F "TOKENS=2 DELIMS==" %%I IN ('FIND /I "Desktop" TEMP.TXT') DO (
ECHO %%I
PAUSE)


  The code has not been tested. Please post if there is any issue.
Floor 3 Posted 2006-10-19 21:52 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
It's considered that the function is completed, but I'm still not completely satisfied. Let's see what other experts have.
See if there's a way to not generate the temporary file temp.reg and a way to not use the extra intermediate variable skipline.
To ensure no mistakes, the method used is: locate the line where is, and then take from the next line of it.

@echo off
reg EXport HKLM\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046} temp.reg >nul
for /f "delims=" %%i in ('find/n "" temp.reg') do set skipline=%%i
for /f "skip=%skipline% tokens=2 delims==" %%a in ('type temp.reg') do ( echo %%~a & GOTO OUT )
:OUT
del temp.reg
pause>nul


[ Last edited by NaturalJ0 on 2006-10-19 at 23:12 ]
Floor 4 Posted 2006-10-20 10:31 ·  中国 山东 青岛 李沧区 联通
初级用户
Credits 140
Posts 8
Joined 2004-08-18 00:00
21-year member
UID 30357
Gender Male
Status Offline
Floor 2.
Chinese version passed.
For other language versions...
The Korean version has spaces in it...

Still thank you all!
Floor 5 Posted 2006-10-20 10:33 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
  Hehe, I didn't explain. My test environment is Windows XP SP2 Chinese version. I don't know what version you are using.
Floor 6 Posted 2006-10-22 04:32 ·  中国 山东 青岛 联通
初级用户
Credits 140
Posts 8
Joined 2004-08-18 00:00
21-year member
UID 30357
Gender Male
Status Offline
My one is Server 2003 SP1 Korean version
XP SP2 Chinese version
The code on the 3rd floor is okay :)
Thanks!
Floor 7 Posted 2006-10-22 05:54 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Hehe, there is a "('FIND /I "Desktop" TEMP.TXT')" in my code, which contains the Chinese character "Desktop", so it won't work on the Korean version of the system...

  Still, Brother NaturalJ0's code in F3 is more universal.
Forum Jump: