Jump to content

Program Files x64 problem - FileCreateShortcut


MNeMiC
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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
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...