Nesting commands in windows batch file and Parsing results recursively -


screenshot

i trying fetch registry entries under hkey_local_machine\software\microsoft\windows nt\currentversion\profilelist , delete if reg_expand_sz key contains value c:\users\sas-

ideal steps script should :

1) registry entries users using :

reg query "hkey_local_machine\software\microsoft\windows nt\currentversion\profilelist"      >> xyz.txt 

2)if users name sas-### (which can in "reg_expand_sz") delete entry :

for /f "skip=10 tokens=* " %%a in (xyz.txt) (        /f "eol=; skip=2 tokens=4 delims=\t" %k in ('reg query "%%a" /t reg_expand_sz') (     if %k == "sas-" (reg delete "%%a") ) ) 

try this:

for /f "tokens=*" %%a in ('     reg query "hklm\software\microsoft\windows nt\currentversion\profilelist"') (         /f "tokens=*" %%b in ('             reg query "%%a" /v "profileimagepath" 2^>nul ^| find "sas-"')                  rem reg delete "%%a"                 echo "%%a" >>c:\names.txt ) 

i've based on querying profileimagepath value, , deleting of keys contain sas-* in value. i've put in few line breaks have remove (just easy viewing on so).

please test first (i've echo'd them text file @ moment), if happy remove rem reg delete line.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -