Page 1 of 1

findstr on regquery command

Posted: 27 Jul 2011 06:50
by stonysleep
i'm trying to save the output of a findstr of a registry query command into a variable within a batch file so i can do some calculations but I always have problems with for /F loops and it doesn't seem to like the way i'm doing it.

the command i'm trying to run which works is:

Code: Select all

reg query HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security | findstr /i level


i want to put the output of this into a variable so i can test it and then proceed executing other commands.

Did some googling and tried to adapt other examples and came up with this which doesn't work:

Code: Select all

for /F "delims=" %%a in ('reg query HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security | findstr /i level') do set var=%%a


Any help much appreciated

Re: findstr on regquery command

Posted: 27 Jul 2011 08:31
by !k
You must use ^|

Re: findstr on regquery command

Posted: 27 Jul 2011 09:26
by stonysleep
like this?

Code: Select all

for /F "delims=" %%a in ('reg query HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security ^| findstr /i level') do set var=%%a