Registry search for files in subdirectories in batch file

1

1

I want to only search in subfolders in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\PRINTERS using a batch file.

I want it to search the subfolders for values named "Name" and to output the Data portion of it to a text file.

Bonus points if you can somehow concatenate the search for files named "Port" and output the data so I don't have to repeat the search.

I want to use the batch file portion because I have a batch file already that runs robocopy for data backups and net use to copy the mapped drives.

This is what I have tried so far, but not much luck.

for /f "usebackq tokens=1-5" %%A in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\PRINTERS"') do ( 
    set ValueOne=%%A
    set ValueTwo=%%B
    set ValueThree=%%C
    set ValueFour=%%D
    set ValueFive=%%E
    @echo Value One = %ValueOne%
    @echo Value Two = %ValueTwo%
    @echo Value Three = %ValueThree%    
    @echo Value Four = %ValueFour%
    @echo Value Five = %ValueFive%

This will output the individual file with all the parts.

reg QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\PRINTERS\Adobe PDF" /v Name /t REG_SZ 

Matt Pielichowski

Posted 2017-01-18T21:26:23.767

Reputation: 11

Batch doesn't handle the registry very well (not at all really). Is there some reason you're defining batch as your scripting language, over PowerShell or VBS? It'd be pretty easy in PowerShell. Having said that, we're not a script-writing service, so please edit your question to show us what you've got/tried so far, and point out exactly where you're getting stuck, and reword you question to be about that problem or risk it being down-voted/closed. – Ƭᴇcʜιᴇ007 – 2017-01-18T21:29:50.363

No answers