Updating PATH variable
We use kixscripts to script package installation to users pc's. Users have locked down environment an dhave little or no local admin rights.
We have packages for Oracle 6i and Oracle8i. The PATH entry for each MUST appear at the front of the PATH variable When both packages exist on one pc the Oracle 8i path entry MUST appear before the 6i entry regardless of in which order they are installed.
I think the best way is for the Oracle 8i MSI to set its entry (C:\Oracle8i_home\Bin) as set at beginning of path. But for 6i install to not have its path entry (C:\ORANT\Bin) in the MSI but have KIX query the PATH for the existence of C:\Oracle8i_home\Bin and if found make the PATH start as C:\Oracle8i_home\Bin;C:\ORANT\Bin;xxxxx;xxxxx but if the C:\Oracle8i_home\Bin is NOT found then the PATH would start as C:\Orant\Bin;xxxxx;xxxxxx
If that is correct how could I get KIX to do that? I could see INSTR but the scripting isn't up to working how to use it acheive what we need.
Any help gratefully received.
Gary
We have packages for Oracle 6i and Oracle8i. The PATH entry for each MUST appear at the front of the PATH variable When both packages exist on one pc the Oracle 8i path entry MUST appear before the 6i entry regardless of in which order they are installed.
I think the best way is for the Oracle 8i MSI to set its entry (C:\Oracle8i_home\Bin) as set at beginning of path. But for 6i install to not have its path entry (C:\ORANT\Bin) in the MSI but have KIX query the PATH for the existence of C:\Oracle8i_home\Bin and if found make the PATH start as C:\Oracle8i_home\Bin;C:\ORANT\Bin;xxxxx;xxxxx but if the C:\Oracle8i_home\Bin is NOT found then the PATH would start as C:\Orant\Bin;xxxxx;xxxxxx
If that is correct how could I get KIX to do that? I could see INSTR but the scripting isn't up to working how to use it acheive what we need.
Any help gratefully received.
Gary
0 Comments
[ + ] Show comments
Answers (7)
Please log in to answer
Posted by:
Secondlaw
18 years ago
Hmmmm.
You could get the registry value:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment[path]
Parse out the values at ";" then add your new variable to the beginning of the path.
Use Regini.exe to add to the path as admin.
I'm not sure if that's what you were looking for or not? Are you looking for an actual script.
You could get the registry value:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment[path]
Parse out the values at ";" then add your new variable to the beginning of the path.
Use Regini.exe to add to the path as admin.
I'm not sure if that's what you were looking for or not? Are you looking for an actual script.
Posted by:
glwday
18 years ago
Posted by:
Secondlaw
18 years ago
Parse was the wrong term for this one. You just need to set a variable, extract the key, append the key to your variable and replace it into your registry.
I'm not familiar with kix, but I did take a look at it. Unfortunately, everytime I tried something with it, it logged me out of my PC.
Can you use an alternative? I can create a Winbatch or autoit script, or even SMS Installer / Wise...
I'm not familiar with kix, but I did take a look at it. Unfortunately, everytime I tried something with it, it logged me out of my PC.
Can you use an alternative? I can create a Winbatch or autoit script, or even SMS Installer / Wise...
Posted by:
glwday
18 years ago
I found this in the scripts section - but it doesn't seem to work. Can anybody see whats wrong?
$mystring=ReadValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path")
$search="C:\Oracle8i_home\bin\"
$replace="C:\Oracle8i_home\bin\;C:\Orant\Bin"
Function SEARCHREPLACE($mystring, $search, $replace)
If Len($mystring)
While InStr($mystring, $search)<>0
$mystring=SubStr($mystring, 1, InStr($mystring, $search)-1) + $replace + SubStr($mystring, InStr($mystring, $search)+Len($search), Len("$mystring")-Len(SubStr($mystring, 1, InStr($mystring, $search)-1))-Len($search))
Loop
$SearchReplace=$mystring
EndIf
EndFunction
$mystring=ReadValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path")
$search="C:\Oracle8i_home\bin\"
$replace="C:\Oracle8i_home\bin\;C:\Orant\Bin"
Function SEARCHREPLACE($mystring, $search, $replace)
If Len($mystring)
While InStr($mystring, $search)<>0
$mystring=SubStr($mystring, 1, InStr($mystring, $search)-1) + $replace + SubStr($mystring, InStr($mystring, $search)+Len($search), Len("$mystring")-Len(SubStr($mystring, 1, InStr($mystring, $search)-1))-Len($search))
Loop
$SearchReplace=$mystring
EndIf
EndFunction
Posted by:
AngelD
18 years ago
okey, so its been along time since I used kixtart but here goes.
$sPath=ReadValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path")
$aPath= split($sPath, ";")
For $i = 0 To Ubound($aPath-1)
If $aPath($i) = "C:\ORANT\Bin"
$sPathValue = "C:\Oracle8i_home\Bin" + $aPath($i)
else
$sPathValue = $aPath($i)
EndIf
If $i <> Ubound($aPath-1)
$sPath = $sPathValue + ";"
Else
$sPath = $sPathValue
EndIf
Next
Sorry for any syntax is incorrect but hope it helps in any way.
EDIT: fixed a code bug ;)
$sPath=ReadValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path")
$aPath= split($sPath, ";")
For $i = 0 To Ubound($aPath-1)
If $aPath($i) = "C:\ORANT\Bin"
$sPathValue = "C:\Oracle8i_home\Bin" + $aPath($i)
else
$sPathValue = $aPath($i)
EndIf
If $i <> Ubound($aPath-1)
$sPath = $sPathValue + ";"
Else
$sPath = $sPathValue
EndIf
Next
Sorry for any syntax is incorrect but hope it helps in any way.
EDIT: fixed a code bug ;)
Posted by:
Secondlaw
18 years ago
By the way... If Autoit is an option:
$CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path")
$AddtoPath1 = ("C:\Oracle8i_home\bin\;")
$AddtoPath2 = ("C:\Orant\Bin;")
$checkstr = StringInstr ($CurrentPath, $AddtoPath1)
$checkstr2 = StringInstr ($CurrentPath, $AddtoPath2)
$NewPath = $CurrentPath
If $CheckStr == 0 then
$NewPath = $AddtoPath1 & $NewPath
EndIf
If $checkstr2 == 0 then
$NewPath = $AddtoPath2 & $NewPath
EndIf
Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath)
Good luck.
$CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path")
$AddtoPath1 = ("C:\Oracle8i_home\bin\;")
$AddtoPath2 = ("C:\Orant\Bin;")
$checkstr = StringInstr ($CurrentPath, $AddtoPath1)
$checkstr2 = StringInstr ($CurrentPath, $AddtoPath2)
$NewPath = $CurrentPath
If $CheckStr == 0 then
$NewPath = $AddtoPath1 & $NewPath
EndIf
If $checkstr2 == 0 then
$NewPath = $AddtoPath2 & $NewPath
EndIf
Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath)
Good luck.
Posted by:
ColinBragg
17 years ago
These are great scripts folks but remember... It's bad practice in this day and age to be modifying the path variable at all. You should really be using the application paths in the registry. This should work in the same way as the path variable. Also because these keys are not just one long entry like path and is seperated for each app you wont have to worry about order.
The spanner in the works.....The application may be hard coded to look at the path variable rather than just attempting to call the executable without a path and letting the OS deal with the rest.
The spanner in the works.....The application may be hard coded to look at the path variable rather than just attempting to call the executable without a path and letting the OS deal with the rest.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.