Solved Need help with IF ELSE

Micro-star international / Ms-7510
September 8, 2009 at 21:31:20
Specs: Microsoft Windows XP Professional, 2.4 GHz / 3071 MB
Hi

I'm not sure how to do this

if %PATH% ends with \ DO NOTHING else add \


IF %PATH% is D:\ DO NOTHING

IF %PATH% is C:\Windows add \
SET PATH1


See More: Need help with IF ELSE

Report •


#1
September 9, 2009 at 02:15:34
Please explain what you're trying to achieve.


Report •

#2
September 9, 2009 at 10:15:11
✔ Best Answer
if not "%path:~-1%"=="\" set path=%path%\


=====================================
Helping others achieve escape felicity

M2


Report •

#3
September 9, 2009 at 10:17:49
I using the code below to get the source path from the registry

REM Registry SourcePath
FOR /F "skip=4 tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath') DO (set check=%%b)
GOTO dt

So if the SourcePath in the registry is C:\ the environment variable for Check is C:\ but
if the SourcePath in the registry is C:\Windows i need to add \ to the end So the environment variable Check will end up being C:\Windows\


Report •

Related Solutions

#4
September 9, 2009 at 10:34:25
Thanks Mechanix2Go thats just what i needed

Thanks for replying Wahine


CODE:

REM 2. Registry SourcePath
FOR /F "skip=4 tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath') DO (set path=%%b)
if not "%path:~-1%"=="\" set path=%path%\


Report •


Ask Question