Error on Google Chrome shortcut

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hisrRB57
Posts: 64
Joined: 13 Jan 2019, 11:43

Error on Google Chrome shortcut

Post by hisrRB57 » 13 Apr 2021, 04:41

This is my script:

Code: Select all

FileGetShortcut, %A_StartMenuCommon%\Programs\Google Chrome.lnk, ChromePath
RegRead, vPath, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
MsgBox, 0, , %ChromePath%`n%vPath%`n
it produces the following output:

c:\Program Files (x86)\Google\Chrome\Application\chrome.exe
c:\Program Files\Google\Chrome\Application\chrome.exe


The strange thing is that the link in the start menu in c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk
points to the second output line.

The impact is that using the chrome.ahk inclusion throws an exception: Chrome could not be found
It has been working for a long time, but recently I re-installed chrome. After that the error occurs.

Any ideas what migth be wrong?

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Error on Google Chrome shortcut

Post by mikeyww » 13 Apr 2021, 06:59

Programs sometimes leave behind invalid links.

There are two start menus. The other one is for the specific user.

Explained: A_StartMenu

Use FileExist when needed.

gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Error on Google Chrome shortcut

Post by gregster » 13 Apr 2021, 07:21

My guess is that you used Chrome's 64-bit version before, and now installed the 32-bit version - which probably install (by default) to different program files directories (like other programs), and the shortcut didn't get updated for some reason.
Perhaps you can simply correct the shortcut to point to Chrome's current location, if you want to keep the current installation.

btw, when I run your code, I get

Code: Select all

C:\Program Files\Google\Chrome\Application\chrome.exe
C:\Program Files\Google\Chrome\Application\chrome.exe
Both point correctly to my Chrome browser's (the 64-bit version) location.

hisrRB57
Posts: 64
Joined: 13 Jan 2019, 11:43

Re: Error on Google Chrome shortcut

Post by hisrRB57 » 14 Apr 2021, 13:50

gregster wrote:
13 Apr 2021, 07:21
My guess is that you used Chrome's 64-bit version before, and now installed the 32-bit version - which probably install (by default) to different program files directories (like other programs), and the shortcut didn't get updated for some reason.
Perhaps you can simply correct the shortcut to point to Chrome's current location, if you want to keep the current installation.

btw, when I run your code, I get

Code: Select all

C:\Program Files\Google\Chrome\Application\chrome.exe
C:\Program Files\Google\Chrome\Application\chrome.exe
Both point correctly to my Chrome browser's (the 64-bit version) location.
This is the issue. I removed chrome and installed the 64 bit version.
Surpise: It got installed in both directories:

c:\program files\Google\chrome ...

and

c:\program files (x86)\Google\Crashreports\...
c:\program files (x86)\Google\Policies\...
c:\program files (x86)\Google\Temp\...
c:\program files (x86)\Google\Update\...

I found a way to move the chrome directory and updated the register, but (oh my oh my) don't trust it for a penny.
It works now however.

Thanks Gregster !!!

hisrRB57
Posts: 64
Joined: 13 Jan 2019, 11:43

Re: Error on Google Chrome shortcut

Post by hisrRB57 » 17 Apr 2021, 03:35

Hi gregster,

A couple of days later I run the follwoing script:

Code: Select all

FileGetShortcut, %A_StartMenuCommon%\Programs\Google Chrome.lnk, ChromePath1
ChromePath2 := ComObjGet("winmgmts:").ExecQuery("Select * from Win32_ShortcutFile where Name=""" StrReplace(A_StartMenuCommon "\Programs\Google Chrome.lnk", "\", "\\") """").ItemIndex(0).Target
RegRead, ChromePath3, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
All are lines from various versions of geekdudes chrome.ahk class.
And what is my surprise:

The variables ChromePath1 - 3 show respectively:

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
C:\Program Files\Google\Chrome\Application\chrome.exe
C:\Program Files\Google\Chrome\Application\chrome.exe

So further investigation required. I will contact Google to do a correct migration to the 64-bits version

hisrRB57
Posts: 64
Joined: 13 Jan 2019, 11:43

Re: Error on Google Chrome shortcut

Post by hisrRB57 » 21 Apr 2021, 02:34

As I received more issues with chrome.ahk I continued digging into the forum for similar problems.

Here is what I found out:

Code: Select all

FileGetShortcut, %A_StartMenuCommon%\Programs\Google Chrome.lnk, ChromePath1
was giving C:\Program Files (x86)\Google\Chrome\Application\chrome.exe as a result, but the link in C:\ProgramData\Microsoft\Windows\Start Menu definitely contains: C:\Program Files\Google\Chrome\Application\chrome.exe.

Then I found Geekdude comments in chrome.ahk (version 1.2):

; By using winmgmts to get the path of a shortcut file we fix an edge case where the path is retreived incorrectly
; if using the ahk executable with a different architecture than the OS (using 32bit AHK on a 64bit OS for example)


That solved the problem I use the 32-bit version and have now switched to the 64-bit version of Autohotkey

:crazy:

Post Reply

Return to “Ask for Help (v1)”