Solved

Command line path system variable edit

Posted on 2004-08-03
7
2,407 Views
Last Modified: 2010-04-13
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
0
Comment
Question by:Steve_L1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 11712260
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
 
LVL 3

Expert Comment

by:saito1
ID: 11713074
0
 
LVL 85

Accepted Solution

by:
oBdA earned 125 total points
ID: 11713342
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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 6

Expert Comment

by:Scott_Willcocks
ID: 11713543
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
 
LVL 7

Expert Comment

by:GATOR420
ID: 11714489
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
 
LVL 6

Expert Comment

by:Scott_Willcocks
ID: 11714521
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 11714548
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

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question