Jump to content

Launch a desktop shortcut


Giampiero
 Share

Recommended Posts

Hi,

I'm trying to launch a desktop shortcut but something doesn't work as expected. This is the code:

$aston = '\Snap1.lnk'
ShellExecuteWait(@DesktopCommonDir & $aston)

I get a system error:

"impossible to find C:\Users\Public\Desktop\Snap1.lnk"

these are the parameters for the shortcut:

Shortcut: destination---> "C:\Program Files\Brainstorm\Aston 3.1\bin\launcher.bat" bin\eStudio.bat "-lAston"

                from--->"C:\Program Files\Brainstorm\Aston 3.1"

General: Snap1.lnk

description: launcher.bat

path: C:\Users\Public\Desktop

Thanks for your help

 

 

 

Link to comment
Share on other sites

1 hour ago, Giampiero said:

I get a system error:

"impossible to find C:\Users\Public\Desktop\Snap1.lnk"

- 1. Have you take a look into the folder : C:\Users\Public\Desktop and can you find a file named Snap1...  there, or is the Name i.e. "xxx - Shortcut.lnk"

- 2. Perhaps the desktop shortcut resides under @DesktopDir -> C:\Users\[Username]\Desktop

Example : I created a desktoplink for a file namend Dummy.exe .

Then I went to C:\Users\[Username]\Desktop and renamed the link to Snap1 (without the .lnk extension, because it is already one )

$sDesktopLink = '\Snap1.lnk'
ShellExecuteWait(@DesktopDir & $sDesktopLink)

worked well !

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I have found there's a difference between Windows 7 and Windows 10. For both Windows 7 and Windows 10, the AutoIt macro @DesktopCommonDir returns "C:\Users\Public\Desktop. That is actually the Windows 7 Public user's desktop. However, in Windows 10, the Public user's desktop is "C:\Users\Public\Public Desktop". I've had to modify some of my scripts to take this into account.

This is what I have found in my scripts here at work. Not sure if Home versions of Windows 10 or Windows 7 are different.

Who lied and told you life would EVER be fair?

Link to comment
Share on other sites

@benched42 "Public Desktop" is just the display name, all Windows 10 systems point to ...\Public\Desktop, the @DesktopCommonDir macro should always return the correct folder path, you can always double check by viewing the "Common Desktop value in registry under:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

More info: https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid
FOLDERID_PublicDesktop

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...