How to reference a path in which the drive letter can change?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
cadu
Posts: 287
Joined: 18 Mar 2012 21:50

How to reference a path in which the drive letter can change?

Post by cadu »

Hi,

I'd appreciate help. I use XYplorer and many other programs in portable mode, stored in an external drive.
Also, some programs have settings that point to other programs (ex. plugins, backup paths, Listary pointing to XYplorer as main file manager, etc).
When there is drive letter change problems just pop-up!
I'm wondering how to reference a path in which the drive letter can change, in order I don't need to specify the exact drive letter in the path.
So, instead of using "G:\Portable\XYplorer.exe", is it possible to use some expression handled by Windows (not only XYPlorer) that would work as "%anydrive%:\Portable\XYplorer.exe"?
The program path itself "\Portable\XYplorer.exe" is always the same. What would change is just the drive letter, from "G:\Portable\XYplorer.exe" to "%anydrive%:\Portable\XYplorer.exe".

I have two situations:
a) All programs are in same external drive. So, same drive letter change is common to all.
b) Programs installed in C: that points to the external drive that may change letter. Considering there are two different drives, I'm not sure if the same workaround for (a) would work here.

Sorry if my explanation is confused, but what I'm looking for is a kind of expression that will give flexibility, similarly I can achieve by using %username% (C:\Users\%username%\AppData) instead of the actual user name (C:\Users\i_am_the_user\AppData).

Many thanks for help!
Cadu

highend
Posts: 13348
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to reference a path in which the drive letter can change?

Post by highend »

There is no 100% reliable way for this.

Best way to do it: http://www.uwe-sieber.de/usbdlm.html
which can assign always the same drive letter
One of my scripts helped you out? Please donate via Paypal

Post Reply