Command line path system variable edit

Hi,

I am building an SMS installer package and as part of the install I need to edit the "Path" system variable so that 2 entries are removed and the rest of the "Path"  system variable to remains in place.  I know that the "Path" system variable exists in the registry at \local_machine\software\......\environment\path but cannot think of a way of using a script to edit the key instead of deleting it or recreating it .

Does anyone know how this can achieved using SMS installer or a third party tool that I could plug into the SMS installer script?

Thanks, Steve
Steve_L1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
If you have access to Windows 2000's resource kit, there's a registry editing command-line tool there (reg.exe, I believe it's called)
Read here: http://www.robvanderwoude.com/index.html
0
saito1Commented:
0
oBdACommented:
You can use setx.exe from the W2k Resource Kit (http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/setx-o.asp) to set the Path variable permanently. Then you can try this script, which will let you add or remove parts of the path. Note that the script is currently in test mode, it will only display the setx command it would otherwise issue, so that you can verify if the new path is built correctly. This will only run on W2k or later.
As usual: No warranties included, use it at your own risk, test it before you apply it in earnest.

====8<----[ChangePath.cmd]----
@echo off
setlocal enabledelayedexpansion
:: *** List of folders to be added:
set AddPath="C:\TestAdd1" "D:\TestAdd2"
:: *** List of folders to be removed:
set RemPath="C:\Service\Tools" "C:\Perl\Bin\"

set WorkPath="%Path:;=" "%"
set NewPath=
for %%a in (%WorkPath%) do call :process %%a
for %%a in (%AddPath%) do set NewPath=!NewPath!%%~a;
:: *** Test mode: Remove the ECHO in front of the following line to "arm" the script
ECHO setx.exe PATHTEST "%NewPath%" -m
goto leave

:process
set Remove=FALSE
for %%a in (%RemPath%) do if /i %1==%%a set Remove=TRUE
if /i %Remove%==TRUE goto :eof
set NewPath=%NewPath%%~1;
goto :eof

:leave
====8<----[ChangePath.cmd]----
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

Scott_WillcocksCommented:
the problem with SMS is that when running the setup on a clients machine it runs the setup under the clients security context

BSMith logs in and SMS sees that he needs this software it pushes it out him it runs on his machine as if BSMith is loading the software.

if BSMith is on a WIN9x client windows 95 98 etc no problem if the SMS installation has A add path to directory set go into the SMS ipf with the SMS installer software and goto view>script editor. and check for add to path is in the script if not goto left panel and select add directory to path and set the path you can use sms variables. when you run this on the WIN9x client all good.

If BSMith is on a WINNT client w2K WXp you will have a problem as a standard use does not have the correct permisions to write to the system path.

This is why Installshield is taking over if you create an msi and active directory assign the package when you deploy the package runs under the windows installer service which can elevate the rights of the package.
0
GATOR420Commented:
Don't know of a way to "edit" the key, but you could definitely use the Reg utility that sirbounty mentioned.

I use it for several things usually, to query if certain keys are there and then run an if statement.

For instance, Reg query HLKM\Software\ORL\WinVNC3\%version%

Queries for what version of VNC they have when I set the version variable.

I then do a Reg delete to delete old entries if it is an outdated version: Reg delete \\%1\%CLE% (%1 being the target computer and %CLE% being a defined path in the registry.)

Then a Reg copy to copy the current settings from an existing computer with the correct registry settings: Reg copy %serv%\%CLE% \\%1\%CLE% /s /f

Works like a champ for me :)
0
Scott_WillcocksCommented:
if you are using SMS installer edit the ipf add the add directory to path.

Just tested it on windows 2K and it works SMS falls over trying to add services not system paths my bad haven't used sms installer for about a year now.
0
sirbountyCommented:
Another method, if the right permissions are in place, and the path should be the same for all users, is to export your key to a path.reg file.
Then simply run
 regedit /s path.reg
from a comman line to silently import it...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.