General discussion

Locked

Updating System Path with a script

By Zengeek ·
I am currently researching different methods of upgrading the Oracle Client software from Ora8 to Ora9 on approximately 3000 desktops. I know how to automate the removal of the old client and installation of the new one, but the system path remains a difficult obstacle for me: the new Oracle path must be in the same place as the old Oracle path, but all the tools I have seen to date (such as pathman.exe) can only append the system path. Is there a way of putting the path elements in a specific place in the path via a script? I need to automate this process to get it done in a timely manner instead of having my techs visit all the desktops just to manually edit the system path. Any ideas?

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by BFilmFan In reply to Updating System Path with ...

You can output the path to a text file with the command:

path > directory\filename

Example:

path > c:\temp\path.txt

Then in your script, you could call that text file as a set of variables.

Collapse -

by Zengeek In reply to

I tried something similar but was unable to change the path in a satisfactory manner. My scripts always run in a shell and the shell's path changes, but not the system path.

Collapse -

by has In reply to Updating System Path with ...

Hi

I encountered and solved this problem a couple of years ago, when we cahnged to Windows XP, and needed a centralized solution, without visiting all macines (we have only 500, but still it's too many).
The rest of my Oracle-client installation was based on batch commandprompt scripts, so I wanted a solution in that "frame".
The problem with the path i commandprompt is it consist of BOTH the user-path and the system-path. And changing the path in commandprompt, don't change the machines systempath.

Well, the solution was this script:

rem Installation-script for update of system-path
rem
rem Hans Henrik Andersen, 20. februar 2003

REM *** Extract from registry to local environment
set TEMPFIL1=%TEMP%\OraPath.txt
set TEMPFIL2=%TEMP%\OraPath.bat
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path >%TEMPFIL1%
java -cp "C:\DStHomeSel" RegToEnv "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path SystemPath <%TEMPFIL1% >%TEMPFIL2%
call %TEMPFIL2%
del %TEMPFIL1%
del %TEMPFIL2%

REM *** Remove "'s from SystemPath
set SystemPath=%SystemPath:"=%

REM *** Operations on SystemPath

REM *** Example: Remove java 1.1.7 from SystemPath
set SystemPath=%SystemPath:;C:\Programmer\Oracle\jre\1.1.8\bin=%
set SystemPath=%SystemPath:C:\Programmer\Oracle\jre\1.1.8\bin;=%
set SystemPath=%SystemPath:C:\Programmer\Oracle\jre\1.1.8\bin=%

REM *** Change system-path for machine
setx.exe Path "%SystemPath%" -m

I don't know where the setx program is from, some guy from our net-support gave it to me.
Short it changes the environment for windows globally (and not the local environment). The -m switch tells setx to change the systems environment, not the users.

It uses a java program for decomposing the output form the reg query command into a "set SystemPath=***" command. It is simple, but too long for the length limit here.

Hans Henrik

Collapse -

by Zengeek In reply to

I actually found a simpler solution using Pathman.exe from the Windows Resource Kit and a batch file.

First, here a couple of things to remember:
1. The Windows registry stores Windows Path elements as %SYSTEMROOT% instead of "C:\Windows" for XP or "C:\WINNT" for Win2k.

2. Calling up the path from a shell or batch file expands these variables.

3. A shell's path environment is not affected by the pathman.exe utility and will remain unchanged unless you use the set command within that shell, and changes are only in effect till you close the shell.

Here is the script I used:
REM************************************
@echo off
pathman.exe /rs "%path%"
rem Old path removed

pathman.exe /as "%path:ora81=ora92%"
rem New path added

rem Now to remove path reduncies...

if %SYSTEMROOT%==C:\WINNT GOTO WIN2k

rem This is for WIN XP
pathman /rs "C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;"
rem Path redundancies removed...
GOTO END

:WIN2k
pathman /rs "C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;"
rem Path redundancies removed...

:END
REM************************************
The basic system path is preserved in the registry because all variables are expanded when calling %PATH%.

%PATH% allows for variable substition in WinXP and Win2K which allowed me to modify the path with the new Oracle home when I used pathman to write back the path to the registry.

Removing explicit Windows path elements was required because %PATH% expands the variable %SYSTEMROOT% from the registry, causing double entries for "C:\Windows\System32"...

I hope that makes sense to you, because it worked for me for both Windows XP and 2000.

Collapse -

by softcorp.us In reply to Updating System Path with ...

Hello Zengeek,

I have a tool that is ideal for your situation:

Softcorp scPATHMAN - System and User Path Management Tool
http://www.softcorp.us/scpathman

If you have any questions, please feel free to contact me.

-----Steve Jackson

CEO/CSA
Software Corporation (Softcorp)

Collapse -

by Zengeek In reply to

I'll have to try it out, but I used my own solution as follows...
I actually found a simpler solution using Pathman.exe from the Windows Resource Kit and a batch file.

First, here a couple of things to remember:
1. The Windows registry stores Windows Path elements as %SYSTEMROOT% instead of "C:\Windows" for XP or "C:\WINNT" for Win2k.

2. Calling up the path from a shell or batch file expands these variables.

3. A shell's path environment is not affected by the pathman.exe utility and will remain unchanged unless you use the set command within that shell, and such changes are only in effect till you close the shell.

Here is the script I used:
REM************************************
@echo off
pathman.exe /rs "%path%"
rem Old path removed

pathman.exe /as "%path:ora81=ora92%"
rem New path added

rem Now to remove path reduncies...

if %SYSTEMROOT%==C:\WINNT GOTO WIN2k

rem This is for WIN XP
pathman /rs "C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;"
rem Path redundancies removed...
GOTO END

:WIN2k
pathman /rs "C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;"
rem Path redundancies removed...

:END
REM************************************
The basic system path is preserved in the registry because all variables are expanded when calling %PATH%.

%PATH% allows for variable substition in WinXP and Win2K which allowed me to modify the path with the new Oracle home when I used pathman to write back the path to the registry.

Removing explicit Windows path elements was required because %PATH% expands the variable %SYSTEMROOT% from the registry, causing double entries for "C:\Windows\System32"...

I hope that makes sense to you, because it worked for me for both Windows XP and 2000.

Collapse -

by Zengeek In reply to Updating System Path with ...

This question was closed by the author

Back to Software Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums