Hello.
Notepad2.exe is an 64bit utility installed in the Program Files folder of Windows. It doesnt exist in the Program Files (x86) folder.
If I create its shortcut with the below code:
FileCreateShortcut, "C:\Program Files\Notepad2\Notepad2.exe",Notepad2.lnk
the created shortcut has instead the path "C:\Program Files (x86)\Notepad2\Notepad2.exe and ofc it doesnt work.
What causes this and how can I fix it?
My OS is Windows 10 Pro 64bit
FileCreateShortcut and Program Files problem.
Re: FileCreateShortcut and Program Files problem.
Does this work for you?
On Windows 7, using AHK 32-bit it actually seems to give me link files with exactly the same contents. With/without the redirection.
Code: Select all
q::
FileCreateShortcut, "C:\Program Files\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2 (error).lnk
if A_Is64bitOS
DllCall("kernel32\Wow64DisableWow64FsRedirection", PtrP,0)
FileCreateShortcut, "C:\Program Files\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2.lnk
return
Last edited by jeeswg on 17 Feb 2019, 17:25, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
FileCreateShortcut and Path Redirection problem.
Helllo.
No, unfortunately it doesnt work at all.
Both resulted shortcuts have in their target path Program Files (x86) instead of Program Files.
Shouldnt the DLL command be enough to bypass the Windows' path redirection?
I also used this small script I found, to edit the resulted shortcut and change its target path to Program Files, but again the path becomes Program Files (x86):
No, unfortunately it doesnt work at all.
Both resulted shortcuts have in their target path Program Files (x86) instead of Program Files.
Shouldnt the DLL command be enough to bypass the Windows' path redirection?
I also used this small script I found, to edit the resulted shortcut and change its target path to Program Files, but again the path becomes Program Files (x86):
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; https://msdn.microsoft.com/en-us/library/xsy6k3ys(v=vs.84).aspx
; https://msdn.microsoft.com/en-us/library/xk6kst2k(v=vs.84).aspx
wsh := ComObjCreate("WScript.Shell")
lnk := wsh.CreateShortcut("<path to existing lnk file or one to create>")
lnk.TargetPath := "D:\"
lnk.Save()
Re: FileCreateShortcut and Program Files problem.
Btw did you try this in AHK x64?
If it works in AHK x64, then in the worst-case scenario you could use AHK x32 with ExecScript to run a temporary x64 script.
Run / RunWait
https://autohotkey.com/docs/commands/Run.htm#ExecScript
If it works in AHK x64, then in the worst-case scenario you could use AHK x32 with ExecScript to run a temporary x64 script.
Run / RunWait
https://autohotkey.com/docs/commands/Run.htm#ExecScript
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: FileCreateShortcut and Program Files problem.
I have installed the 64bit version of AHK. and I am running Windows 10 64bit.
I used a batch file to create a shortcut and the Program Files path was kept. only AHK changes it to Program Files (x86)
I will try your suggestion.
I used a batch file to create a shortcut and the Program Files path was kept. only AHK changes it to Program Files (x86)
I will try your suggestion.
Re: FileCreateShortcut and Program Files problem.
Btw could you post the code for the batch file, because AHK can usually execute batch commands directly. I had meant to suggest batch files as a workaround if other things failed, although I haven't used it before to create shortcut files.
Since I didn't have any problems doing this with AHK x32 in Windows 7, perhaps Windows 10 has changed something re. handling x32 processes, or perhaps something about the FileCreateShortcut command no longer works with Windows 10.
One possible workaround. Although the Recent folder doesn't work with exe files I believe. But if this did work, it might confirm that certain things do still work on Windows 10.
Since I didn't have any problems doing this with AHK x32 in Windows 7, perhaps Windows 10 has changed something re. handling x32 processes, or perhaps something about the FileCreateShortcut command no longer works with Windows 10.
One possible workaround. Although the Recent folder doesn't work with exe files I believe. But if this did work, it might confirm that certain things do still work on Windows 10.
Code: Select all
q::
;vPath := "C:\Program Files\7-Zip\7zFM.exe"
vPath := "C:\Program Files\test.txt"
SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
DllCall("shell32\SHAddToRecentDocs", UInt,0x3, Str,vPath) ;SHARD_PATHW = 0x3
vPath1 := "C:\Users\" A_UserName "\AppData\Roaming\Microsoft\Windows\Recent\" vNameNoExt ".lnk"
MsgBox, % FileExist(vPath1)
vPath2 := A_Desktop "\z my test lnk.lnk"
FileCopy, % vPath1, % vPath2
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
- theimmersion
- Posts: 181
- Joined: 09 Jul 2016, 08:34
- Location: Serbia
Re: FileCreateShortcut and Program Files problem.
huh... using just this:
FileCreateShortcut, "C:\Program Files (x86)\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2.lnk
or
FileCreateShortcut, "C:\Program Files\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2.lnk
makes the shortcut with the correct address on my system. Also win 10 64 pro.
Maybe theres something else wrong with the OS instead?
FileCreateShortcut, "C:\Program Files (x86)\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2.lnk
or
FileCreateShortcut, "C:\Program Files\Notepad2\Notepad2.exe", %A_Desktop%\Notepad2.lnk
makes the shortcut with the correct address on my system. Also win 10 64 pro.
Maybe theres something else wrong with the OS instead?
Who is online
Users browsing this forum: RandomBoy and 394 guests