This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Last path demiliter in environment strings
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Nov 04, 2013
10:56 AM
Last path demiliter in environment strings
Hi,
I need to add a path without last path delimiter in environment strings. According to the log, the property I write in the Environment table is correctly formatted (without last path delimiter), but value written by WriteEnvironmentStrings has the path delimiter:
The Environment table:
[CODE]Environment Name Value Component_
NewEnvironment1 *=-MyEnvString [MyProperty] MyComponent[/CODE]
So, after installation, it's impossible to use paths like %MyEnvString%\SubDirectory (user need to search for %MyEnvString%SubDirectory, that is not usual).
Is there a way to do that ?
Thanks for help,
Adrien
I need to add a path without last path delimiter in environment strings. According to the log, the property I write in the Environment table is correctly formatted (without last path delimiter), but value written by WriteEnvironmentStrings has the path delimiter:
WriteEnvironmentStrings: Name: MyEnvString, Value: C:\Test\, Action 536870913
...
Property(S): MyProperty = C:\Test
The Environment table:
[CODE]Environment Name Value Component_
NewEnvironment1 *=-MyEnvString [MyProperty] MyComponent[/CODE]
So, after installation, it's impossible to use paths like %MyEnvString%\SubDirectory (user need to search for %MyEnvString%SubDirectory, that is not usual).
Is there a way to do that ?
Thanks for help,
Adrien
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Nov 05, 2013
03:29 AM
Hi,
I have solved the problem by building the Environment table in a custom action. So I can directly add the path without delimiter, instead of using a formatted property in the Value field of the Environment table (which seems to automatically add a delimiter...).
in my case (custom action based on a Delphi dll function) it looks like this:
[CODE]procedure InitEnvironmentTable(hInstall: MSIHandle);
var
Db, View: MSIHandle;
Path, Query: string;
begin
if bsMsiGetProperty(hInstall, 'MYPATH', Path, MAX_PATH) then
begin
Path := ExcludeTrailingPathDelimiter(Path);
MsiLogStringFmt(hInstall, 'Adding MYPATH to Environment table... (%s)', [Path]);
Db := MsiGetActiveDatabase(hInstall);
if Db <> 0 then
try
Query := 'INSERT INTO `Environment` (`Environment`, `Name`, `Value`, `Component_`) ' +
'VALUES (''NewEnvString'', ''*=-MyEnvString'', ''' + Path + ''', ''MyComponent'') TEMPORARY';
try
if MsiDatabaseOpenView(Db, PAnsiChar(Query), View) <> ERROR_SUCCESS then
MsiLogString(hInstall, MsiGetLastErrorRecord)
else if MsiViewExecute(View, 0) <> ERROR_SUCCESS then
MsiLogString(hInstall, MsiGetLastErrorRecord)
else
MsiLogString(hInstall, 'MYPATH added to Environment table.');
finally
MsiCloseHandle(View);
end;
finally
MsiCloseHandle(Db);
end;
end;
end;[/CODE]
Hope this help !
Adrien
I have solved the problem by building the Environment table in a custom action. So I can directly add the path without delimiter, instead of using a formatted property in the Value field of the Environment table (which seems to automatically add a delimiter...).
in my case (custom action based on a Delphi dll function) it looks like this:
[CODE]procedure InitEnvironmentTable(hInstall: MSIHandle);
var
Db, View: MSIHandle;
Path, Query: string;
begin
if bsMsiGetProperty(hInstall, 'MYPATH', Path, MAX_PATH) then
begin
Path := ExcludeTrailingPathDelimiter(Path);
MsiLogStringFmt(hInstall, 'Adding MYPATH to Environment table... (%s)', [Path]);
Db := MsiGetActiveDatabase(hInstall);
if Db <> 0 then
try
Query := 'INSERT INTO `Environment` (`Environment`, `Name`, `Value`, `Component_`) ' +
'VALUES (''NewEnvString'', ''*=-MyEnvString'', ''' + Path + ''', ''MyComponent'') TEMPORARY';
try
if MsiDatabaseOpenView(Db, PAnsiChar(Query), View) <> ERROR_SUCCESS then
MsiLogString(hInstall, MsiGetLastErrorRecord)
else if MsiViewExecute(View, 0) <> ERROR_SUCCESS then
MsiLogString(hInstall, MsiGetLastErrorRecord)
else
MsiLogString(hInstall, 'MYPATH added to Environment table.');
finally
MsiCloseHandle(View);
end;
finally
MsiCloseHandle(Db);
end;
end;
end;[/CODE]
Hope this help !
Adrien
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)