Hi,
I am trying to launce the program I just installed and it requires one environment variable. I set the environment variable in my install script, I set the variable in the “BeforeInstall:” section of my run command and I also issue a “refresh” of the environment.
As far as I can debug, the variable gets set properly using the following code:
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
function SendTextMessageTimeout (hWnd : HWND; Msg : UINT; wParam : WPARAM; lParam : PAnsiChar;
fuFlags : UINT; uTimeout : UINT; out lpdwResult : DWORD) : LRESULT;
external 'SendMessageTimeout{#AW}@user32.dll stdcall';
procedure RefreshEnvironment;
var
S: AnsiString;
MsgResult: DWORD;
begin
S := 'Environment';
SendTextMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, 0,
PAnsiChar (S), SMTO_ABORTIFHUNG, 5000, MsgResult);
end;
function SetEnvironmentVariable (lpName : String; lpValue : String) : Boolean;
external 'SetEnvironmentVariable{#AW}@kernel32.dll stdcall';
procedure SetDataPathEnv;
begin
SetEnvironmentVariable ('I3K_DATAPATH', ExpandConstant ('{#MyJobDst}'));
RefreshEnvironment;
end;
[Run]
Filename: "{app}\{#MyAppName}.exe"; Parameters: "{code:MyParameters}"; Description: "Launch {#MyAppName}"; BeforeInstall: SetDataPathEnv; Flags: nowait postinstall skipifsilent
The app will launch but it tells me the environment is not set. This only happens for the first install because the value has not been set yet.
Are there any known ways to solve this problem? It would be nice to launch the app for our customers.
Best Regards,
David Fileccia
Senior Systems Engineer | HEMISPHERE GNSS
Office: 6860 Little Twin Road, Germantown, OH 45327, USA
Corporate: 8515 E. Anderson Drive, Scottsdale, AZ 85255, USA
dfil...@hgnss.com | www.hgnss.com
Disclaimer: This message (including any other messages, attachments, or files within) contains information that may be confidential or privileged and is the property of Hemisphere GNSS, Inc. and its subsidiaries (‘Hemisphere’). It is intended for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, copy, distribute, print, retain, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. Any opinions or views expressed within are solely those of the author and do not necessarily represent those of Hemisphere. Thank you for your cooperation.
Hi,
I am trying to launce the program I just installed and it requires one environment variable. I set the environment variable in my install script, I set the variable in the “BeforeInstall:” section of my run command and I also issue a “refresh” of the environment.
As far as I can debug, the variable gets set properly using the following code:
...
[Run]
Filename: "{app}\{#MyAppName}.exe"; Parameters: "{code:MyParameters}"; Description: "Launch {#MyAppName}"; BeforeInstall: SetDataPathEnv; Flags: nowait postinstall skipifsilentThe app will launch but it tells me the environment is not set. This only happens for the first install because the value has not been set yet.
Are there any known ways to solve this problem? It would be nice to launch the app for our customers.
Best Regards,
David Fileccia
Senior Systems Engineer | HEMISPHERE GNSS
On Thursday, July 8, 2021, 19:56:10, Bill Stewart wrote:
Also note the sentence in the Remarks section: "This function has no effect on the system environment variables or the environment variables of other processes."
I think the problem here is that while SetEnvironmentVariable will set the environment for the current process and all children started from the current process, Inno does not start [Run] entries (other than those with runascurrentuser flag) from the same process that runs [Code], so those environment changes will not be visible.