/build/static/layout/Breadcrumb_cap_w.png

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

0 Comments   [ + ] Show comments

Answers (7)

Posted by: Secondlaw 18 years ago
Third Degree Blue Belt
0
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.
Posted by: glwday 18 years ago
Orange Belt
0
Unfortunately I don't know how to parse and get the C:\Orant\Bin as the second entry when relevant. This is part of a software install kixscript which runs at SYSTEM so we can update PATH - just the users can't.

A script would be great!!

Thanks in advance
Posted by: Secondlaw 18 years ago
Third Degree Blue Belt
0
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...
Posted by: glwday 18 years ago
Orange Belt
0
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
Posted by: AngelD 18 years ago
Red Belt
0
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 ;)
Posted by: Secondlaw 18 years ago
Third Degree Blue Belt
0
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.
Posted by: ColinBragg 17 years ago
Senior Yellow Belt
0
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ