Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can I make relative paths for shortcuts?  (Read 8975 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Can I make relative paths for shortcuts?
« on: September 09, 2017, 06:48:28 PM »
First, let me explain what I want to do. In the process of moving from Windows XP up to Windows 10, I switch back and forth with the hope that in time I will get used to using Windows 10 It is going on two years now and I still get tuck in Windows 10. So I have to revert back to Windows XP until my head clears.

Well, I like to use shortcuts. Everywhere, not just on the desktop, but inside of directories. A number of my shortcuts refer to items in a partition I have named DATA. As the name would suggest, it is not a Windows system partition.

Now here is the problem for me. I want to use the same set of shortcuts on either XP, 7 or 10. I do not want to have three versions of each shortcut. When I reboot the computer to another OS, the drive letters might change. Some do, some don't. The shortcuts often are to drive D:\ as you can see in the small PNG image attached.

So here is my question. Is there a way to have variable that would contain the rightr drive letter? And how would you use such a variable in the shortcut?
One shortcut, named AnyHow,  has this:
Code: [Select]
   D:\ Kohn-II\AnyHow Le's say I put this in the right place:
Code: [Select]
set  MY_DATA = D:\
would I put this in the shortcut?
Code: [Select]
%%MY_DATA%%Kohn-II\AnyHow
I have yet to try that. Would it work? Is there a better way?
Thanks for any help. ;)

BTW: Is there an easy way to
 - edit a bunch of shortcuts all at once?  ;D

[attachment deleted by admin to conserve space]

Salmon Trout

  • Guest
Re: Can I make relative paths for shortcuts?
« Reply #1 on: September 10, 2017, 01:35:05 AM »
The problem with using variables in a path for a shortcut would be that Windows expands the variable when you create the shortcut, not when you use it later on. This is just an idea - I have not tried it on a multiboot machine - you could try using the SUBST command. This allows you to assign a new, second drive letter to any drive. Suppose you have a drive which is D: in one OS, and E: in another, and F: in a third. You could pick a letter which none of them use - let's say Q: - and use SUBST in each OS to make that letter an alias to the shifting letter. After that a shortcut containing Q: at the start should work on each OS. The simplest way to do this might be to add a batch script to your user startup folder in each OS, something like this

Code: [Select]
subst K: J:\

The first parameter is a drive letter plus colon, the second is a folder, which can be a root folder - note the slash.

K: is the new drive letter and J:\ points to an existing folder, root or otherwise, on an existing drive letter. Henceforth K:\folder\file.ext will be treated the same as J:\folder\file.ext

I say henceforth - if you do the above at the command prompt (say you want to experiment and master the concept) it will only last until a reboot, which is why you would put it into a batch to run at startup, once you have got the letters straight.

Use subst /? at the prompt to see the help.

You could also edit the registry to get the same results, but I think the above is simpler.

Wikipedia article here

https://en.wikipedia.org/wiki/SUBST

Code: [Select]
C:\Users\Mike>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.


As for editing links in bulk, here is a VBScript I found (that I have not tried yet). I suggest you try it out on copies first!

https://community.spiceworks.com/scripts/show/298-change-shortcut-lnk-target-paths-in-bulk




« Last Edit: September 10, 2017, 01:46:49 AM by Salmon Trout »

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can I make relative paths for shortcuts?
« Reply #2 on: September 13, 2017, 01:09:17 AM »
Salmon Trout,
Thank you very much. It w ould have taken me a very long time  to ever discover what you made clear. I forgot about the
Code: [Select]
subst K: J:\concept. the subsk command. Ir has been around for along time.  :)