Jump to content

How to overcome rare Windows shortcut file weirdness?


Mbee
 Share

Recommended Posts

I just ran into a serious problem (at least in Windows 7): In some cases, the data returned from FileGetShortcut() and _FileGetShortcutEx() for a .lnk file does not match the paths shown in the Explorer properties! That is, If you look at the external properties of a particular lnk file (in this case to an executable) in Explorer, everything is exactly correct. If you press "Open file location", it finds and shows the correct file.  But the two functions in question return a different (and wrong) path.

I'm not sure, but my guess is that they read and parse the actual contents of the .lnk file itself, which for some inexplicable reason, in rare cases, differs from what's shown in the Explorer properties window.  I encountered this issue while working on my own shortcut analysis tool, which identified an example of this weirdness as a bad shortcut even though the shortcut actually points to the correct file.  In Explorer, the shortcut in question pointed correctly to an exe file located in C:\Program Files, whereas the two functions above returned the target path as wrongly being located in C:\Program Files (x86).

I don't believe that those two functions have a bug, but rather they must be looking at data that's different than what Explorer shows.  Why they're different is unknown to me, but might possibly have something to do with .lnk tracking or whatever.  A google search for others encountering this issue found nothing relevant.

Anyway, what I need is some way of obtaining the same path as shown in Explorer's properties window.  With that info, I can compare that with what the FileGetShortcut() functions return in order to identify a weird shortcut, which will allow me to repair the shortcut.

Does anyone know how I could obtain that Explorer properties data?  Thanks!

Link to comment
Share on other sites

Run it using autoit_64.exe instead. The shortcut probably uses the %ProgramFiles% shorthand to point to where the file is.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

8 minutes ago, BrewManNH said:

Run it using autoit_64.exe instead. The shortcut probably uses the %ProgramFiles% shorthand to point to where the file is.

Hey, great thinking!  But please, could you check my thinking on how use autoit_64.exe instead of the default? Do I just need to add the line: "#AutoIt3Wrapper_UseX64=Y", or do I need to do something else as well?

ETA: There must be something else, since the above still ended up using the 32-bit Aut2exe...

Edited by Mbee
Link to comment
Share on other sites

Do you have the full version of Scite4AutoIt3 installed?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Post your script and we can see what's going on.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

4 minutes ago, BrewManNH said:

Post your script and we can see what's going on.

I'll be happy to if you still think it's necessary, because the "#AutoIt3Wrapper_Aut2exe" directive worked perfectly.

 

ETA: That worked perfectly! (i.e., the code) Thank you enormously!

Edited by Mbee
Link to comment
Share on other sites

Are you compiling this to an exe before testing it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

2 minutes ago, BrewManNH said:

Are you compiling this to an exe before testing it?

Yes, because I had been using the debugger, which is 32-bit.  Was that wrong?

Edited by Mbee
Link to comment
Share on other sites

You can run it directly from within SciTE to test it before compiling it. No idea what debugger you're referring to though.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...