24
2
While developing my product, my test device has several versions of the application installed at the same time. However, in order to get the absolute paths that my application is using to work, I need to switch out or rename the folders so that the version I want to test has the right path, say C:\Program Files\My Company\My App\My App.exe
. I've made a shortcut that targets this path, but if this shortcut is opened when none of the versions currently have that path then the shortcut will automatically update itself, thinking the file has moved permanently. This caused silent failures until I discovered what was happening. I didn't know this was a feature of Windows shortcuts until now.
So my question is simple. Is there any way to turn this feature off? Globally is good but a per-shortcut solution would be better.
Using a batch file instead of a shortcut is one solution, but I'm wondering if there's any way to make this work while still using a shortcut.
I'm using Windows 10 Home and Windows 7 Home.
10What I've done in the past is use a batch file (
.bat
) with a simple command, e.g.start "" "C:\path\to\file.exe"
. – Bob – 2017-07-19T02:25:54.7731Have you tried creating a symbolic link (using the
mklink
command) instead of a.lnk
file instead? Or do those get updated too? – JAB – 2017-07-19T02:55:03.9501@JAB symlinks shouldn't be updated, but have certain disadvantages (require admin privs, cannot pass arguments, etc.). Though they do work well if those aren't a problem. – Bob – 2017-07-19T03:04:49.010
3I thought making the shortcut read-only would work (I'm sure it used to) but having tested I see that it doesn't. This is because the shortcut isn't rewritten; the target is found when the shortcut is run. Just so no-one else tries. – Chris H – 2017-07-19T09:37:32.850
@Bob I believe you don't need
start
. Just"C:\path\to\file.exe"
should work as the entire batch file, right? – Kyle Delaney – 2017-07-19T13:48:09.133@KyleDelaney True, if you provide the full path then
– Bob – 2017-07-19T16:25:24.390start
isn't necessary. I use it because I tend to combine it with App Paths, which only work with theShellExecute
family (includingstart
).Mark shortcut as read-only. – user364455 – 2017-07-19T18:32:18.563
1@PetSerAl as I said above, that doesn't work. – Chris H – 2017-07-20T13:01:45.563
@ChrisH It work for me. Even when Windows can find moved file, it does not update path in shortcut. And when you then create new file in original shortcut location target, it will open that new file. – user364455 – 2017-07-20T13:14:41.440
1@PetSerAl The OP's problem appears to be that clicking an obsolete shortcut launches a different version. Read-only doesn't solve that. It just means the search has to happen again next time. – Chris H – 2017-07-20T13:16:03.730
@ChrisH As long as file at shortcut target path exist, no search will be performed and that file will be used, even if it is not the file, from which shortcut was created. So, only practical difference from
.bat
/.cmd
solution is that: if file does not exist, it will not fail, but try to find original file. Otherwise behavior would be identical. – user364455 – 2017-07-22T03:36:55.037@PetSerAl exactly. My reading (and that of those who wrote the answers including the accepted one) is that the OP wants an obsolete link to fail rather than silently pointing to an arbitrary more recent version. Running/testing multiple versions of software is hard enough without Windows trying to help. – Chris H – 2017-07-22T07:46:18.950
@ChrisH I do not see where OP ask that it must fail in that case. OP ask how to prevent shortcut from updating, not how to prevent Windows from searching for moved file. And read-only doing exactly that: prevent shortcut from updating. You must have very great mind reading capabilities, as you not only can correctly understand what OP want, but also assert that others (that of those who wrote the answers including the accepted one) have the same understanding of question as you. – user364455 – 2017-07-22T08:09:30.580