Search code examples
autohotkeyshortcut-file

FileCreateShortcut behaves weird


I am using

FileCreateShortcut, %A_WorkingDir%\some.exe, %A_Desktop%\Some.lnk

to create the shortcut. But if desktop contains a folder named "Some" for some reason it decides to create a shortcut for it rather than a shortcut for the target specified. Also, it quite hard to delete these shortcuts. If it deleted it also deletes the folder. Why is that happening and how to avoid it?

I am using Windows 10 if that is helpful. I have tried running the script as admin, it doesn't make any difference. Also, It works fine and creates a shortcut as long as the folder with the same name on the desktop doesn't exist.


Solution

  • I tried to recreate the exact situation with the same names and locations, but it ran successfully. It created a separate link from an existing folder with the same name. Deleting the shortcut had no issues and left the folder there. I also tried running it with an invalid .exe path, but it still ran successfully and had similar behavior to what I had previously mentioned.

    While I don't know why this is happening to you, I would recommend ensuring that you're running the latest Windows 10 updates (and there are no pending updates, waiting for a restart) and the latest version of AutoHotkey.

    In my case, I'm running Win10 version 1903, build 18362.145 and AutoHotkey v1.1.30.03.