reg.exe output

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to use reg.exe to query a remote machines
registry value. I can accomplish this, but the output is
as follows...
------------------------
reg.exe version 2.0 !

\\server\hklm....blah blah
dbname SQLSERVER10
-------------------------
i would like to only get SQLSERVER10 from the output, so i
can store it in a database.

just thought i could get some ideas before i start.
Any suggestions would be greatly appreciated.

thanks in advance,
Warren
 
i'm trying to use reg.exe to query a remote machines
registry value. I can accomplish this, but the output is
as follows...
------------------------
reg.exe version 2.0 !

\\server\hklm....blah blah
dbname SQLSERVER10
-------------------------
i would like to only get SQLSERVER10 from the output, so i
can store it in a database.

just thought i could get some ideas before i start.
Any suggestions would be greatly appreciated.

thanks in advance,
Warren

We normally need real output to have something to filter on.

That is difficult with blah ...

Assuming the relevant line is, with some dropped spaces:

dbname REG_SZ SQLSERVER10

@echo off
for /f "tokens=1-2,*" %%A in (
'reg-exe "yourbla here"^|find "dbname"') do set dbname=%%C
echo %dbname%

That is as close as I can get to your virtual environment.
 
here's what i came up with....

@echo off
set regkey="\\server10\HKlm\software\communication
center\database"
set regvalue="dbserver"
for /f "Skip=4 Tokens=3" %%a in ('REG.EXE QUERY %
regkey% /v %regvalue%') do @echo %%a
 
Back
Top