I read it backwards and assumed the underscores were to show where the spaces were and not actually part of the path. Now I understand why you think there is a bug. However, as I said, I cannot reproduce the behaviour you describe. Using
FileCreateShortcut, "S:\IT - Software\Tools\AppName.exe", test.lnk, the shortcut's target is exactly
"S:\IT - Software\Tools\AppName.exe" (copy-pasted from the properties dialog). S drive does not exist. If I map S drive, the result is the same. If I also create the folders and put AppName.exe in, the result is the same.
AutoHotkey doesn't do any processing of the target path. It merely passes the parameter value exactly as is to
IShellLink::SetPath. Why do anything more?
If you open the lnk file in a text or hex editor, is the path the same as it appears in the properties dialog?
The properties dialog sometimes lies about the target of the shortcut - probably due to
link resolution.
You may also try this, which I would expect to produce a shortcut file with the same properties.
Code: Select all
l := FileGetShellLink(A_ProgramsCommon "\AppName\Update now.lnk")
l.Path := """S:\IT - Software\Tools\AppName.exe"""
l.Save()
FileGetShellLink(lnkpath) {
if !FileExist(lnkpath)
FileOpen(lnkpath, "w")
Loop Files, % lnkpath
lnkpath := A_LoopFileLongPath
SplitPath lnkpath, name, dir
if !(sl := ComObjCreate("Shell.Application").NameSpace(dir).ParseName(name).GetLink())
throw
return sl
}