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

Reading REGDB_STRING_EXPAND Values


1 reply to this topic

johnwestenhaver

johnwestenhaver
  • Members
  • 3 posts

Posted 25 March 2003 - 00:24

Two questions:

1. I'm adjusting the application path on WinNT machines by wrtiting to the HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path registry key. That's working just fine. On a custom un-install, however, when I go to read this key using this code, the string returned gets munged:

// make sure the shared directory is removed from the path
// but only if we are reasonably certain it was added in the first place
if( bIsWindowsNT ) then
szTestLine = TARGETDIR ^ @LITERAL_SHARED;
// get the current path
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
nResult = RegDBGetKeyValueEx( szKey, "Path", nType, szOldPath, nSize );
// figure out if we need to do anything
// we can assume that our path has delimiters on _both_ sides
// because we added it ourselves
nResult = StrFindEx( szOldPath, ";" + szTestLine + ";",  0 );
if( nResult >= 0 ) then
// found it!
...

What happens is that the %SystemRoot% entries on the path have the initial % and the S removed, as well as the trailing %. This happens to all environment variables on the path, not just %SystemRoot% -- so I can't trap for it. It looks like this in the registry:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel ...

And it looks like this from a messagebox in InstallShield:

ystemRoot\system32;ystemRoot;ystemRoot\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel ...

I'm working on XP Pro with InstallShield Pro 7 SP1. I searched Usenet for any mention of this, but couldn't find anything.

2. Many, many people on Usenet have asked how to change a WinNT path in such a way that the change takes effect immediately, without rebooting. No one gave an answer that I could see. Anyone know how to do this?

prozacrefugee

prozacrefugee
  • Members
  • 38 posts

Posted 10 April 2003 - 21:20

This is why you're getting the problem - it's escaping out, so %S and % are not part of the string.

IS Help - The percent sign (%) also has a special function in InstallScript; it is used as the first character of a format specifier, which is a sequence of characters that is used with functions such as Sprintf and SprintfBox to indicate how the value stored in a variable should be displayed on screen.

Not sure how you can cope with this, maybe you can tokenize the return by semicolins, then add %S to the front and % to the end. Does this only happen with SystemRoot?

On the second question there is a .rul file on this site called RefreshEnvironment.rul that will do that. It can take some time to work for env. variables, so I usually call it like this:

RefreshEnvironment();
Delay(1);
RefreshEnvironment();