reg query using a variable

Microsoft Windows xp professional w/serv...
August 12, 2010 at 12:58:15
Specs: Windows XP
Is there a way to remove trailing spaces from a variable? I need to trim the variable, then export it to a text file, then call another .bat script.

example script:
Set str="abcdefg "
echo %str% > C:\TEMP\output.txt
call "C:\TEMP\another.bat"


See More: reg query using a variable

Report •


#1
August 12, 2010 at 13:15:28
I fail to see why you can't:
set var=S-1-5-18
reg query "HKU\%var%\Software\Microsoft"


Report •

#2
August 12, 2010 at 14:34:47
It's because the variable has trailing spaces. Sorry, I was editing the post as you were replying.

Report •

#3
August 12, 2010 at 20:32:59
@echo off
set var=variable with spaces
set var=%var: =%
cls
echo %var%
pause

Report •

Related Solutions

#4
August 13, 2010 at 05:36:31
Great! You wouldn't believe the headache this was causing me.

Report •


Ask Question