Pedro Sales
Pedro Sales

Reputation: 553

Setting a variable from FOR loop

I have the following for loop

for /f "tokens=1* delims=;" %%a in ("%FORMS60_PATH%") do (
        echo %%a | findstr /i /r SAM
    )

what it does is read a registry key, FORMS60_PATH. the registry key as the value - c:\sam;c:\sape

It searchs the key if it has SAM in it and returns c:\sam if valid The question is ...how can I set this value to a variable?

Upvotes: 0

Views: 81

Answers (1)

npocmaka
npocmaka

Reputation: 57252

for /f "tokens=1* delims=;" %%a in ("%FORMS60_PATH%") do (
        echo %%a | findstr /i /r SAM && (
           set "variable=%%a"
        )
    )
echo %variable%

?

Upvotes: 1

Related Questions