Solved

Command line path system variable edit

Posted on 2004-08-03
7
2,401 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
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
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
Comment Utility
0
 
LVL 82

Accepted Solution

by:
oBdA earned 125 total points
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 6

Expert Comment

by:Scott_Willcocks
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now