When I use the Run command by setting the path directly to the executable (e.g. Run, "C:\Program Files\Paint.NET\PaintDotNet.exe"), it works fine. However, if I set the path to the lnk file, it will fail (e.g. Run, "C:\Users\Public\Desktop\Paint.NET.lnk"). This does not happen on other applications. If I type the link such as "C:\Users\Public\Desktop\Paint.NET.lnk" via Run(Windows key + r), it just runs fine.
Also FileGetShortcut retrieves the wrong path from the link file of Paint.Net.
PaintDotNet_lnk := A_DesktopCommon . "\Paint.NET.lnk" FileGetShortcut, %PaintDotNet_lnk%, PaintDotNet_Target msgbox % PaintDotNet_TargetThe code above shows this path, "C:\Program Files (x86)\Paint.NET\PaintDotNet.exe," despite the fact that the correct path is "C:\Program Files\Paint.NET\PaintDotNet.exe."
If anybody has this problem or a solution to retrieve the correct path, let me know. The code below demonstrates the problem. Thanks.
#Noenv #singleinstance, Force #persistent SetWorkingDir %A_ScriptDir% PaintDotNet := "C:\Program Files\Paint.NET\PaintDotNet.exe" PaintDotNet_lnk := A_DesktopCommon . "\Paint.NET.lnk" FileGetShortcut, %PaintDotNet_lnk%, PaintDotNet_Target Return ^1:: ;works Run, "%PaintDotNet%",,UseErrorLevel, pid if ErrorLevel msgbox Error: %PaintDotNet% else msgbox %pid% Return ^2:: ;does not work IfExist, %PaintDotNet_lnk% { Run, "%PaintDotNet_lnk%",,UseErrorLevel, pid if ErrorLevel msgbox Error: %PaintDotNet_lnk% else msgbox %pid% } Return ^3:: ;does not work. Somehow the retrieved path contains "(x86)" in it. Run, "%PaintDotNet_Target%",,UseErrorLevel, pid if ErrorLevel msgbox Error: %PaintDotNet_Target% else msgbox %pid% Return ^4:: ;does not work ; Run, %comspec% /c "C:\Users\Public\Desktop\Paint.NET.lnk",,UseErrorLevel, pid ;this doesn't work either Run, %comspec% /c "%PaintDotNet_lnk%",,UseErrorLevel, pid if ErrorLevel msgbox Error: %PaintDotNet_lnk% else msgbox %pid% Return