Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
if I run the following code:
@echo off
FOR /F "tokens=3* delims= " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "DAEMON Tools"') DO set string=%%B
echo %string%
I get this string:"C:\Program Files\Daemon Tools\daemon.exe" -lang 1033
how do I extract the following parts from that string?1) "C:\Program Files\Daemon Tools\daemon.exe"
2) "C:\Program Files\Daemon Tools"
thx!

You let the parser do the work for you.
@echo off
FOR /F "tokens=3* delims= " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "DAEMON Tools"') DO CALL :parse %%B
echo %string%
GOTO :EOF
:parse
set string=%~1
set string2=%~dp1

for those who already read what I just posted here, nevermind, Razor2.3 is right, th following script gets me what I wanted:
@echo off
FOR /F "tokens=3* delims= " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "DAEMON Tools"') DO CALL :parse %%B
echo %string%
echo %string2%pause
GOTO :EOF:parse
set string=%~1
set string2=%~dp1
thx for your help!note that the delimiter gets screwed up when posting this code, it's supposed to be "tab-space", without the hyphen and the quotes of course...
computing.net removes the tab, so if you just copy and paste it, it will not work ;-)

![]() |
Newbie creating a batch f...
|
Concatenating files using...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |