findstr on regquery command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stonysleep
Posts: 2
Joined: 27 Jul 2011 06:43

findstr on regquery command

#1 Post by stonysleep » 27 Jul 2011 06:50

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: findstr on regquery command

#2 Post by !k » 27 Jul 2011 08:31

You must use ^|

stonysleep
Posts: 2
Joined: 27 Jul 2011 06:43

Re: findstr on regquery command

#3 Post by stonysleep » 27 Jul 2011 09:26

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

Post Reply