Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Environment Variables update


6 replies to this topic

spdygnlz

spdygnlz
  • Full Members
  • 106 posts

Posted 26 January 2006 - 23:47

I have a problem where I need to register some .dll files, but they depend on files in another directory. I put this directory in the PATH variable, but it seems that InstallShield and any processes it spawns do not read the new PATH var. The way my predecessor handled this issue was to set the PATH var, spawn a new instance of the same setup and quit the current one. Not a very elegant solution, if I may say.

Does anyone know how IS can refresh or update it's environment variables while it's running? Thanks!

-- spdygnlz --

ramalaks

ramalaks
  • Members
  • 19 posts

Posted 30 January 2006 - 18:28

szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
Delay( 1 );


te above should flush the all registry updates to all the applications

spdygnlz

spdygnlz
  • Full Members
  • 106 posts

Posted 30 January 2006 - 19:30

Thanks! I actually tried that from an external C++ dll and it didn't seem to work so I kinda just forgot about it. I haven't tried it from InstallScript itself. I'll try and let you know how it goes.

-- spdygnlz --

spdygnlz

spdygnlz
  • Full Members
  • 106 posts

Posted 02 February 2006 - 20:49

Didn't work how I expected it to.

CODE

#ifdef _LOG_DEBUG_MSG_
MessageBox("Path var", INFORMATION);
LaunchApp("cmd", "/C echo BEFORE >> C:\PATH.txt");
LaunchApp("cmd", "/C echo %path% >> C:\PATH.txt");
#endif

Disable( LOGGING );
g_bRestart = AddCommonPath ();
Enable( LOGGING );
if(g_bRestart == TRUE) then
  szEnv = "Environment";
  pEnv = &szEnv;
  SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv);
  Delay(1);
 
#ifdef _LOG_DEBUG_MSG_
LaunchApp("cmd", "/C echo AFTER >> C:\PATH.txt");
LaunchApp("cmd", "/C echo %path% >> C:\PATH.txt");

#endif
endif;



And this is what I got.

CODE

BEFORE
C:\Program Files\InstallShield 10.5\System;C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Starbase\StarGate SDK\Lib;C:\Program Files\Starbase\StarGate SDK\Bin;C:\Program Files\MathWorks\MATLAB Component Runtime\v72\runtime\win32;C:\WINNT\Microsoft.NET\Framework\v1.1.4322;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Program Files\KiX2010.450
AFTER
C:\Program Files\InstallShield 10.5\System;C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Starbase\StarGate SDK\Lib;C:\Program Files\Starbase\StarGate SDK\Bin;C:\Program Files\MathWorks\MATLAB Component Runtime\v72\runtime\win32;C:\WINNT\Microsoft.NET\Framework\v1.1.4322;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Program Files\KiX2010.450



I stepped through it and made sure that everything ran how it was suppsed to.

-- spdygnlz --

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 06 February 2006 - 17:56

I don't think the InstalLScript engine listens to WM_WININICHANGE broadcasts (I know the Windows Installer engine doesn't)

spdygnlz

spdygnlz
  • Full Members
  • 106 posts

Posted 06 February 2006 - 17:59

That's the conclusion that I've come to as well... any other ideas?

-- spdygnlz --

jdsipes

jdsipes
  • Members
  • 2 posts

Posted 31 August 2006 - 23:33

This might be a little late to be useful but the way that I have gotten around this is to use a custom function and a bat file. I have a setEnvVar function that both creates the environment variable in the registry and writes the env variable to a bat file that I keep secreted away in the SUPPORTDIR (use SET) . The function has grown over time to include various logic for PATH or for if the value already exists, etc. When I need to launch an app or do something that requires one of the new env variables I just write the command out to the bat file and run the bat file. I then delete the command from the bat file, leaving all the previously set env vars for the next time I need to use it during the install. I also often catch any result from the command line and pipe this off to a log file. At the end of the install I delete the bat file from the SUPPORTDIR to keep things clean.

JD

Edited by jdsipes, 31 August 2006 - 23:34.