1752785 Members
6142 Online
108789 Solutions
New Discussion юеВ

DOS batch procedure

 
Jose Mosquera
Honored Contributor

DOS batch procedure

Hi guys,

I need help to script this in DOS batch syntax. First I need obtain any registry data entry into the root key HKEY_LOCAL_MACHINE where the string 2.34.1.32 is present:

C:\>scanreg -s 2.34.1.32 -d lm|find "Data"
Data : "2.13.0.20,2.12.0.20,2.34.1.32"
Data : "2.34.1.32,2.34.1.54"
Data : "2.34.1.32"

So I need catch on-the-fly this output and extract second field separated by ":" and then execute to each string line the following command:
regfind -r "2.13.0.20,2.12.0.20"

In other words, the follwing executions will be done:
regedit "2.13.0.20,2.12.0.20,2.34.1.32" -r "2.13.0.20,2.12.0.20"
regedit "2.34.1.32,2.34.1.54" -r "2.13.0.20,2.12.0.20"
regedit "2.34.1.32" -r "2.13.0.20,2.12.0.20"

Rgds.
2 REPLIES 2
Ivan Ferreira
Honored Contributor

Re: DOS batch procedure

For this kind of jobs, as you are an HP-UX expert, probably you will find unxtools very usefull:

http://unxutils.sourceforge.net/

They work very whell.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Robert Gralak
New Member

Re: DOS batch procedure

Hi Jose!

I think it will be a good, one-line solution:

reg_srch.bat

@FOR /F "usebackq tokens=2* delims=:" %%a IN ('scanreg -s 2.34.1.32 -d lm|find "Data"') do regedit %%a -r "2.13.0.20,2.12.0.20"

For searching any other strings, ie.:

reg_srch "2.13.0.20,2.12.0.20" 2.34.1.32

@FOR /F "usebackq tokens=2* delims=:" %%a IN ('scanreg -s %2 -d lm|find "Data"') do regedit %%a -r %1

Best regards