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-10 16:54
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to modify the target of a shortcut View 3,374 Replies 16
Original Poster Posted 2008-11-20 07:57 ·  中国 江苏 扬州 电信
高级用户
★★★
Credits 620
Posts 329
Joined 2007-12-05 15:34
18-year member
UID 104754
Gender Male
Status Offline
Often put some green small tools in the USB flash drive for use.
And created shortcuts (*.lnk) of these small tools in the USB flash drive.
Because different computers have different drive letter settings for the USB flash drive, it is quite troublesome to use these shortcuts. You must modify the target of the shortcut again to use it.

Now please ask experts to write a BAT that directly changes the target path of the shortcut.
Requirements:
1. First retrieve the current drive letter where the USB flash drive is located.
2. Modify the target of the shortcuts in the current folder. (This BAT is placed in the same folder as the shortcuts) (Actually, just modify the drive letter ----- change I:\*\ to g:\*)
Floor 2 Posted 2008-11-20 09:39 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
You can use some USB flash drive "Start Menu" software, such as PSMenu

PSMenu - Portable Start Menu (Portable Start Menu)
http://www.appinn.com/psmenu-portable-start-menu/
Floor 3 Posted 2008-11-20 10:03 ·  中国 江苏 扬州 江都区 电信
高级用户
★★★
Credits 620
Posts 329
Joined 2007-12-05 15:34
18-year member
UID 104754
Gender Male
Status Offline
Thanked the software tried upstairs.
Not very easy to use. Not very convenient.

Still want to use BAT to solve.
Can you give an idea...

(Just change the target path of a *.lnk)
Floor 4 Posted 2008-11-20 10:08 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Change the target path of all shortcuts in a directory... ( Vbscript )
Change The Target Path Of All Shortcuts In A Directory... ( Vbscript )
Floor 5 Posted 2008-11-20 10:57 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Why not replace all shortcuts with batch scripts? This way, relative paths can be used.
start "" "tool\test.exe"
Floor 6 Posted 2008-11-20 17:54 ·  中国 山东 济南 联通
新手上路
Credits 10
Posts 7
Joined 2008-11-18 19:58
17-year member
UID 131378
Gender Male
Status Offline
I have also encountered this problem.

The temporary method is the same as the one above, and multiple folders and files can be opened simultaneously.

start "" 工具\下载\FlashGet\FlashGet.exe
start "" 工具\网络\Tencent\qq\QQ.exe
start "" 文件\素材\MM相片\
start "" 工具\娱乐\MP3列表.m3u
start "" http://www.google.com/

But this bat cannot search the upper - level directory.
If you have many commonly used tools and it is inconvenient to put them in the root directory,
you will definitely create a folder to put all the shortcuts.
In this way: your shortcuts are in
g:\Common Tool Shortcuts\

If you use bat to replace lnk, then
the directory where your bat file is located is
g:\Common Tool Shortcuts\

And the files you want to point to are in
g:\Tools\QQ\QQ2008.exe
g:\Music\Qianqian Quiet Listening.ttpl
In this case, it cannot be searched.

This is the first problem.
The second problem is: then a bunch of bat files placed there are not very nice to look at.
So it is best to use one bat to get it done.
Looking forward to it...

I just started learning bat the second day, hope to get more guidance.
Floor 7 Posted 2008-11-20 18:07 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
XP seems to automatically search...
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 8 Posted 2008-11-20 18:09 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
The directory where your bat file is located is
g:\Common Tool Shortcuts\

And the files you want to point to are in
g:\Tools\QQ\QQ2008.exe
g:\Music\Qianqian Quiet Listening.ttpl
In this case, it cannot be found

Like this: start "" \Tools\QQ\QQ2008.exe

. means the current directory
.. means the parent directory
\ means the root directory
Floor 9 Posted 2008-11-20 18:13 ·  中国 山东 济南 联通
新手上路
Credits 10
Posts 7
Joined 2008-11-18 19:58
17-year member
UID 131378
Gender Male
Status Offline
New problem again,

My computer
start "" 123.txt
start + half-width space + "" + half-width space + program, file or folder path
Can't search subdirectories now, actually.
I remember it was okay yesterday
What's going on?
The error message is "Cannot find '123.txt' (quotes added by myself in the prompt)
Adding "" to 123.txt doesn't work either
start "" \123.txt doesn't work either
It should be a problem with the computer, heh

Frequent registry modifications today, did I accidentally change something
Which registry entries might cause 123.txt to not be found, please
Thanks!

[ Last edited by zxjing on 2008-11-20 at 18:19 ]
Floor 10 Posted 2008-11-20 18:20 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
It will only first look in the current directory, then in the "environment variables", and will not look in other places.
Floor 11 Posted 2008-11-20 18:51 ·  中国 山东 济南 联通
新手上路
Credits 10
Posts 7
Joined 2008-11-18 19:58
17-year member
UID 131378
Gender Male
Status Offline
Thank you everyone for your help, the problem has been solved.
Solution reference
http://www.cn-dos.net/forum/viewthread.php?tid=41923&page=1&sid=TUH4wS#pid290700
The required tools all have links in this post.
Thanks again to the enthusiastic tireless
Floor 12 Posted 2008-11-20 18:53 ·  中国 山东 济南 联通
新手上路
Credits 10
Posts 7
Joined 2008-11-18 19:58
17-year member
UID 131378
Gender Male
Status Offline
Use the link from post 11 in this thread. Use the code from post 10 and the attachment from post 1 in the linked post, then make some minor adjustments.

[ Last edited by zxjing on 2008-11-20 at 18:54 ]
Floor 13 Posted 2008-11-20 22:21 ·  中国 江苏 扬州 电信
高级用户
★★★
Credits 620
Posts 329
Joined 2007-12-05 15:34
18-year member
UID 104754
Gender Male
Status Offline
Thank you all again.

But if you just use BAT, there are no icons.

Still not very good.

I think of a stupid way.

Make several shortcut icons with different paths (usually USB disks: I, H, G and other drive letters)

Then, choose one of them, and it will be okay.

Once again, please ask the experts for advice. What can be simplified or optimized in the above method with BAT...
Floor 14 Posted 2008-11-21 08:41 ·  中国 湖北 荆门 电信
初级用户
★★
Credits 186
Posts 117
Joined 2006-08-14 14:50
19-year member
UID 60491
Status Offline
1. Change the target drive letter of all shortcuts to Z:
2. Create a BAT file with the content to map the current drive letter to Z: using subst

Or use HTA to manage and make it similar to a toolbar style.
Floor 15 Posted 2008-11-21 13:04 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
LinkChanger (http://fcsoft.by.ru/), but it doesn't support command line.

Forum Jump: