Reputation: 3
Alright so I was trying to delete the shell data in the registry. I can get to it and get all of the information right, but I want to automate it for all users. The one I can use right now only targets a specific file.
reg delete "HKEY_USERS\S-1-5-21-3793956547-500355711-2568367668-1002\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags" /f
What I wanted to do was skip the input for S-1-5-21
and have it target all of the keys within HKEY_USERS
. This way I can get all of the shell data deleted with the press of a button.
I am not sure if there is a variable for this, or maybe I am going in the wrong direction here. Any input is appreciated and I will attempt to answer any questions I can.
Upvotes: 0
Views: 211
Reputation: 38613
Something like this may very well suit your needs, it is very likely language dependent, and blind automated removal of registry subkeys is not my recommendation.
@Echo Off
For /F "EOL=E Delims=" %%A In ('Reg Query HKU /S /F Bags /K'
) Do Echo=Reg Delete "%%A" /F&&Echo=Reg Add "%%A"
Timeout -1
remove the two instances of Echo=
and the last line if you're happy with the output and wish to continue.
Upvotes: 0
Reputation:
To enumerate the HKEY_USERS you can Reg Query within a For /f
@Echo off
Set "Hive=HKEY_USERS"
For /F "delims=" %%A in (
'Reg Query "%Hive%" ^|findstr "%Hive%\S-1-5-21" '
) Do Echo %%A
Replace Echo with any cmd you like to execute.
Sample scrambled output:
> SO_41773670.cmd
HKEY_USERS\S-1-5-21-2140113576-3579786329-1990256020-1001
HKEY_USERS\S-1-5-21-2140113576-3579786329-1990256020-1001_Classes
HKEY_USERS\S-1-5-21-2140113576-3579786329-1990256020-1005
HKEY_USERS\S-1-5-21-2140113576-3579786329-1990256020-1006
Upvotes: 1