Sign in to follow this  
Followers 0
MNeMiC

Program Files x64 problem - FileCreateShortcut

3 posts in this topic

Okay so I have a bunch of automatic installer scripts that I've done over the years.

Now I was forced to convert to Windows7 due to getting an SSD-drive.

The problem I'm having now is that all my custom installers create a shortcut in my Windows Directory to allow me to use RUN and just write the name of the shortcut to start the program.

To create the shortcut, I use the FileCreateShortcut function.

Like this:

;Add a shortcut to WINDOWS-directory for fast RUNning
$var = @ProgramFilesDir & "\WindowsMenuPlus\WindowsMenuPlus.exe"
FileCreateShortcut ($var, @WINDOWSDIR & "\windowmenuplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\wmplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\menuplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\windowmenu.lnk")

The problem here is that the @ProgramFilesDir gets set to the C:\Program Files(x86)\ directory instead of where I have installed the program.

What's curious about this is that I'm using @ProgramFilesDir to actually set the installation directory earlier in the script, and then it sets it to C:\Program Files\, as I want it to do.

$var = @ProgramFilesDir & "\WindowsMenuPlus\"
Send ($var)

Any thoughts on why the @ProgramFilesDir gets a different value when it's used later in the script?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Thanks, that helped, it's still strange why it would do that though.

Also, it didn't help that I wrote the file name incorrectly (WindowsMenuPlus instead of WindowMenuPlus)

;x64 Fix
If Not @AutoItX64 And @OSArch = 'x64' Then
    $var = EnvGet('ProgramW6432') & "\WindowMenuPlus\WindowMenuPlus.exe"
Else
    $var = @ProgramFilesDir & "\WindowMenuPlus\WindowMenuPlus.exe"
EndIf

;Add a shortcut to autostart
FileCreateShortcut  ($var, @StartupDir & "\WindowMenuPlus.lnk")

;Add a shortcut to WINDOWS-directory for fast RUNning
FileCreateShortcut ($var, @WINDOWSDIR & "\windowmenuplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\wmplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\menuplus.lnk")
FileCreateShortcut ($var, @WINDOWSDIR & "\windowmenu.lnk")
Edited by MNeMiC

Share this post


Link to post
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
Sign in to follow this  
Followers 0