PDA

View Full Version : Installscript system variable "FOLDER_APPLICATIONS64" bugged?



adboll
07-17-2014, 06:18 PM
I have an Installscript project using the installing and uninstalling events with the following code. The problem is on install, FOLDER_APPLICATIONS64 system variable resolves correctly to C:\ProgramFiles on a x64 OS. However, on uninstall, the same system variable FOLDER_APPLICATIONS64 resolves to C:\ProgramFiles (x86). Additionally on uninstall, the other related system variable FOLDER_APPLICATIONS resolves to the same thing C:\ProgramFiles (x86). Why does this only happen on uninstall???



#define PSQL_EXE_PATH FOLDER_APPLICATIONS64^"PostgreSQL\\9.3\\bin\\psql.exe"

export prototype Server_Installing();
function Server_Installing()
STRING szServiceLoc, szServiceCmdLineArgs, szServiceCmdLine, szTest, szTest2, szSourceDir;
begin
szServiceCmdLineArgs = "/passive /norestart /i ";
szServiceLoc = SRCDIR^"AMDS Server Discovery Service.msi";
LongPathToQuote(szServiceLoc, TRUE);
szServiceCmdLine = szServiceCmdLineArgs + szServiceLoc;

//Install AMDS Server Discovery Service
LaunchAppAndWait(MSI_EXEC, szServiceCmdLine, LAAW_OPTION_WAIT);

//Install AMDS Environment
LaunchAppAndWait(LOC_ENV, "/v\"ADDLOCAL=AmdsServerEnvironment SQUADRON=" + SQUADRON + " /qr\"", LAAW_OPTION_WAIT);

//Install AMDS Database
//Install installation pgpass.conf file for Postgres authentication on installing the database using the SQL file
//1. Delete any existing versions of the file
//2. Copy new one and rename on copy
//nResult = Is(FILE_EXISTS, POSTGRES_FOLDER_PATH^"pgpass.conf");
if (Is(FILE_EXISTS, USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf") = TRUE) then
DeleteFile(USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf");
endif;
CopyFile(SRCDIR^"pgpassInstall.conf", USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf");
szTest = PSQL_EXE_PATH;
szSourceDir = SRCDIR^"AMDSServerInstall.sql";
LongPathToQuote(szSourceDir, TRUE);
szTest2 = "-U postgres -w -f " + szSourceDir;
LaunchAppAndWait(PSQL_EXE_PATH, "-U postgres -w -f " + szSourceDir, LAAW_OPTION_WAIT);

end;

export prototype Server_UnInstalling();
function Server_UnInstalling()
STRING szSourceDir, szTest, szTest2, szTest3, szTest4;
begin
//Remove AMDS Server Discovery Service
LaunchAppAndWait(MSI_EXEC, "/qn /x {D440CE2E-0B33-449F-81DC-C3439D457A5C}", LAAW_OPTION_WAIT);

//Remove AMDS Environment
LaunchAppAndWait(MSI_EXEC, UNINST_ENV_ARGS, LAAW_OPTION_WAIT);

//Remove AMDS Database
//Install uninstallation pgpass.conf file for Postgres authentication on uninstalling the database using the SQL file
//1. Delete any existing versions of the file
//2. Copy new one and rename on copy
if (Is(FILE_EXISTS, USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf") = TRUE) then
DeleteFile(USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf");
endif;
CopyFile(SRCDIR^"pgpassUninstall.conf", USER_APPDATA_POSTGRES_FOLDER_PATH^"pgpass.conf");
szSourceDir = SRCDIR^"AMDSServerUninstall.sql";
LongPathToQuote(szSourceDir, TRUE);
szTest2 = "-U postgres -w -f " + szSourceDir;
szTest = PSQL_EXE_PATH;
szTest3 = FOLDER_APPLICATIONS64;
szTest4 = FOLDER_APPLICATIONS;
LaunchAppAndWait(PSQL_EXE_PATH, "-U postgres -w -f " + szSourceDir, LAAW_OPTION_WAIT);

//Recursive cleanup data folder for AMDS database since Postgres installer purposely does not remove
if (Is(PATH_EXISTS, FOLDER_APPLICATIONS64^"PostgreSQL") = TRUE) then
DeleteDir(FOLDER_APPLICATIONS64^"PostgreSQL\\9.3\\Data", ALLCONTENTS);
DeleteDir(FOLDER_APPLICATIONS64^"PostgreSQL\\9.3", ONLYDIR);
DeleteDir(FOLDER_APPLICATIONS64^"PostgreSQL", ONLYDIR);
endif;

end;