Add to Path Envronment Variable
Windows 7
I am trying to add to the Path system Environment Variable through a transform and just can't seem to get it to work.
Should it work, and if so, should it work on Windows 7?
Answers (14)
- Are you adding to the System environment or the User environment? If the former, be aware that the Windows Installer engine is dumb in that, after adding to the System environment, it does not broadcast the change to Windows, meaning that you need to reboot to bring the change into effect.
You can do it in the MSI environment variable and Path:Table Name = Environment
NewEnvironment2 *=-PATH [~];c:\oreclient\instantclient_12_1 NetUsers.exe
NewEnvironment1 *=-OCI_LIB64 [~];c:\oreclient\instantclient_12_1 NetUsers.exe
This can also be done via Powershell also:
if (-not (Test-Path env:TNS_NAMES))
{
[Environment]::SetEnvironmentVariable('TNS_NAMES', 'C:\Oracle\instantclient_12_1', 'Machine')
}
Else
{
Write-Host "Variable exists"
}
Function Global:Add-Path {
<#.SYNOPSIS
PowerShell function to modify Env:Path in the registry
.DESCRIPTION
Includes a parameter to append the Env:Path
.EXAMPLE
Add-Path -NewPath "D:\Downloads"
#>
Param (
[String]$NewPath ="C:\Oracle\instantclient_12_1"
)
Begin {
Clear-Host
} # End of small begin section
Process {
Clear-Host
$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"
$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path
$NewPath = $OldPath + ’;’ + $NewPath
Set-ItemProperty -Path "$Reg" -Name PATH –Value $NewPath -Force
} #End of Process
}
Add-Path
Yes, the transform is being applied because other actions, such as copying files and adding reg entries, are working.
installExecuteSequence / "WriteEnviromentStrings" = PERL_PATH
I tried again with a reboot and no difference. Below is the log. I'm not sure which step would indicate whether it failed or not.
=== Logging started: 2011-05-10 08:47:28 ===
Action start 08:47:28: INSTALL.
Action start 08:47:28: SetRootDrive.
Action ended 08:47:28: SetRootDrive. Return value 1.
Action start 08:47:28: AppSearch.
Action ended 08:47:28: AppSearch. Return value 1.
Action start 08:47:28: FindRelatedProducts.
Action ended 08:47:28: FindRelatedProducts. Return value 1.
Action start 08:47:28: LaunchConditions.
Action ended 08:47:28: LaunchConditions. Return value 1.
Action start 08:47:28: ValidateProductID.
Action ended 08:47:28: ValidateProductID. Return value 1.
Action start 08:47:28: CostInitialize.
Action ended 08:47:28: CostInitialize. Return value 1.
Action start 08:47:28: FileCost.
Action ended 08:47:28: FileCost. Return value 1.
Action start 08:47:28: CostFinalize.
Action ended 08:47:28: CostFinalize. Return value 1.
Action start 08:47:28: MigrateFeatureStates.
Action ended 08:47:28: MigrateFeatureStates. Return value 0.
Action start 08:47:28: SetODBCFolders.
Action ended 08:47:28: SetODBCFolders. Return value 1.
Action start 08:47:28: InstallValidate.
Action ended 08:47:29: InstallValidate. Return value 1.
Action start 08:47:29: SetInstallLocation.
Action ended 08:47:29: SetInstallLocation. Return value 1.
Action start 08:47:29: InstallInitialize.
Action ended 08:47:29: InstallInitialize. Return value 1.
Action start 08:47:29: AllocateRegistrySpace.
Action ended 08:47:29: AllocateRegistrySpace. Return value 1.
Action start 08:47:29: ProcessComponents.
Action ended 08:47:30: ProcessComponents. Return value 1.
Action start 08:47:30: UnpublishComponents.
Action ended 08:47:30: UnpublishComponents. Return value 1.
Action start 08:47:30: UnpublishFeatures.
Action ended 08:47:30: UnpublishFeatures. Return value 1.
Action start 08:47:30: StopServices.
Action ended 08:47:30: StopServices. Return value 1.
Action start 08:47:30: DeleteServices.
Action ended 08:47:30: DeleteServices. Return value 1.
Action start 08:47:30: UnregisterComPlus.
Action ended 08:47:30: UnregisterComPlus. Return value 1.
Action start 08:47:30: SelfUnregModules.
Action ended 08:47:30: SelfUnregModules. Return value 1.
Action start 08:47:30: UnregisterTypeLibraries.
Action ended 08:47:30: UnregisterTypeLibraries. Return value 1.
Action start 08:47:30: RemoveODBC.
Action ended 08:47:30: RemoveODBC. Return value 1.
Action start 08:47:30: UnregisterFonts.
Action ended 08:47:30: UnregisterFonts. Return value 1.
Action start 08:47:30: RemoveRegistryValues.
Action ended 08:47:30: RemoveRegistryValues. Return value 1.
Action start 08:47:30: UnregisterClassInfo.
Action ended 08:47:30: UnregisterClassInfo. Return value 1.
Action start 08:47:30: UnregisterExtensionInfo.
Action ended 08:47:30: UnregisterExtensionInfo. Return value 1.
Action start 08:47:30: UnregisterProgIdInfo.
Action ended 08:47:30: UnregisterProgIdInfo. Return value 1.
Action start 08:47:30: UnregisterMIMEInfo.
Action ended 08:47:30: UnregisterMIMEInfo. Return value 1.
Action start 08:47:30: RemoveIniValues.
Action ended 08:47:30: RemoveIniValues. Return value 1.
Action start 08:47:30: RemoveShortcuts.
Action ended 08:47:30: RemoveShortcuts. Return value 1.
Action start 08:47:30: RemoveEnvironmentStrings.
Action ended 08:47:30: RemoveEnvironmentStrings. Return value 1.
Action start 08:47:30: RemoveDuplicateFiles.
Action ended 08:47:30: RemoveDuplicateFiles. Return value 1.
Action start 08:47:30: RemoveFiles.
Action ended 08:47:30: RemoveFiles. Return value 1.
Action start 08:47:30: RemoveFolders.
Action ended 08:47:30: RemoveFolders. Return value 1.
Action start 08:47:30: CreateFolders.
Action ended 08:47:30: CreateFolders. Return value 1.
Action start 08:47:30: MoveFiles.
Action ended 08:47:30: MoveFiles. Return value 1.
Action start 08:47:30: InstallFiles.
Action ended 08:47:31: InstallFiles. Return value 1.
Action start 08:47:31: DuplicateFiles.
Action ended 08:47:31: DuplicateFiles. Return value 1.
Action start 08:47:31: PatchFiles.
Action ended 08:47:31: PatchFiles. Return value 1.
Action start 08:47:31: BindImage.
Action ended 08:47:31: BindImage. Return value 1.
Action start 08:47:31: CreateShortcuts.
Action ended 08:47:31: CreateShortcuts. Return value 1.
Action start 08:47:31: RegisterClassInfo.
Action ended 08:47:31: RegisterClassInfo. Return value 1.
Action start 08:47:31: WriteRegistryValues.
Action ended 08:47:31: WriteRegistryValues. Return value 1.
Action start 08:47:31: WriteIniValues.
Action ended 08:47:31: WriteIniValues. Return value 1.
Action start 08:47:31: RegisterFonts.
Action ended 08:47:31: RegisterFonts. Return value 1.
Action start 08:47:31: InstallODBC.
Action ended 08:47:31: InstallODBC. Return value 0.
Action start 08:47:31: RegisterTypeLibraries.
Action ended 08:47:31: RegisterTypeLibraries. Return value 1.
Action start 08:47:31: SelfRegModules.
Action ended 08:47:31: SelfRegModules. Return value 1.
Action start 08:47:31: RegisterComPlus.
Action ended 08:47:31: RegisterComPlus. Return value 1.
Action start 08:47:31: InstallServices.
Action ended 08:47:31: InstallServices. Return value 1.
Action start 08:47:31: StartServices.
Action ended 08:47:31: StartServices. Return value 1.
Action start 08:47:31: RegisterUser.
Action ended 08:47:31: RegisterUser. Return value 1.
Action start 08:47:31: SetPPM_TRACK6056.
Action ended 08:47:31: SetPPM_TRACK6056. Return value 1.
Action start 08:47:31: RegisterProduct.
Action ended 08:47:31: RegisterProduct. Return value 1.
Action start 08:47:31: PublishComponents.
Action ended 08:47:31: PublishComponents. Return value 1.
Action start 08:47:31: PublishFeatures.
Action ended 08:47:31: PublishFeatures. Return value 1.
Action start 08:47:31: PublishProduct.
Action ended 08:47:31: PublishProduct. Return value 1.
Action start 08:47:31: ConfigurePerl.
Action ended 08:47:31: ConfigurePerl. Return value 1.
Action start 08:47:31: CONFIGURE_PPM2.
Action ended 08:47:31: CONFIGURE_PPM2. Return value 1.
Action start 08:47:31: RelocatePerl.
Action ended 08:47:31: RelocatePerl. Return value 1.
Action start 08:47:31: GenerateHTML.
Action ended 08:47:31: GenerateHTML. Return value 1.
Action start 08:47:31: InstallFinalize.
Action ended 08:49:58: InstallFinalize. Return value 1.
Action ended 08:49:58: INSTALL. Return value 1.
MSI (s) (C4:68) [08:49:58:654]: Product: ActivePerl 5.6.1 Build 638 -- Installation operation completed successfully.
MSI (s) (C4:68) [08:49:58:670]: Windows Installer installed the product. Product Name: ActivePerl 5.6.1 Build 638. Product Version: 5.6.638. Product Language: 1033. Manufacturer: ActiveState. Installation success or error status: 0.
=== Logging stopped: 2011-05-10 08:49:58 ===
Environment = NewEnvironment1
Name = *+-Path
Value = [INSTALLDIR]bin;[~]
Component = _cff2fc4b3373b379e1b060ad865b95a6
I am creating the mst in AdminStudio 10, but I opened it in ORCA to read the table. I have tried making the change with ORCA, but msiexec complained that the mst was corrupted.
I think with the + it will only create it if it doesn't exist and obviously the PATH statement will always exists.
EDIT - just tested on xp and +-/=- seem to do the same thing
look for something like this in your log
Action 15:03:08: WriteEnvironmentStrings. Updating environment strings...
MSI (s) (38:C8) [15:03:08:280]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=13200)
MSI (s) (38:C8) [15:03:08:280]: Executing op: UpdateEnvironmentStrings(Name=PATH,Value=[INSTALLDIR]bin,Delimiter=;,Action=-1610612735,)
MSI (c) (24:28) [15:03:08:280]: Note: 1: 2262 2: Billboard 3: -2147287038
WriteEnvironmentStrings: Name: PATH
Value:[INSTALLDIR]bin
If not, next thing is, are there any conditions on the component or feature that the component belongs to
MSI (s) (1C:AC) [10:32:16:000]: Skipping action: WriteEnvironmentStrings (condition is false)
Any ideas as to why?
I can't seem to find a setting that would tell it to skip that step. I can set the value manually or using the set cmd so I don't think its a policy.
so that the conversation will remain readable.