Search code examples
installationnsis

Can using Locate in C:/ cause issues?


I'm making a installer for a GTA modification. When the user executes the .exe the first thing it does before showing any GUI is searching for where GTA-SA.exe is located.

I've written common install locations:

# Most common directories where GTA SA can be found

# Default installation directory from GTA SA setup
!define DEFAULT_DIR "$PROGRAMFILES\Rockstar Games\GTA San Andreas\"

# Default installation directory from Steam version
!define STEAM_DIR "$PROGRAMFILES\Steam\steamapps\common\Grand Theft Auto San Andreas"
!define OTHER_DIR_STEAM "D:\SteamLibrary\steamapps\common\Grand Theft Auto San Andrea"

# MixMods recommend users to install their GTA SA folder into Documents
!define MIXMODS_DIR "$DOCUMENTS"

And this is my Locate function inside .onInit code:

# Makes a search into the most common GTA installation folders to
# check where the GTA_SA.exe (or gta-sa.exe) is located
${locate::Open} "${STEAM_DIR}|${MIXMODS_DIR}|C:\|$PROGRAMFILES|${OTHER_DIR_STEAM}|D:\" `\
                /F=1 \
                /D=0 \
                /M=gta?sa.exe \
                /A=-HIDDEN|-SYSTEM \
                /-PN=Temp|WINDOWS` $0

Can searching through C:\ drive cause issues to the user (Specially in slow HDDs)? If so, what would be the best practice to make this search?


Solution

  • I think I get what you are trying to do.

    You want to first check if GTA is installed and then you want to get the exact directory where it is installed.

    Checking the Steam registry entries didn't work for you though because it could also be installed from another platform.

    If I were you I would check this registry directory: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall".

    All the programs wich can be uninstalled are located here, wich should include GTA, even if it was installed using some other platform than Steam.

    You can then find the path where the game is installed in the GTA registry.

    For more information I would recommend checking out this post here.

    Let me know if I could help you with your issue.