Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've written this little batch script to help me auto-clean the registries of 300+ identical PC's of some very specific registry keys. It works right up to the point of passing the key variable to the "reg delete %1" command.

@echo off
C:
cd C:\Program Files\McAfee\Common Framework\
framepkg.exe remove=agent /silent

setlocal
for /F %%c in ('REG QUERY HKLM\SOFTWARE /s^|FIND "HKEY_"^|findstr /L /I /C:"mcafee"')  do call :delete %%c
endlocal
goto :EOF

:delete
reg delete /f %1
pause

Any and all debugging help would be extremely appreciated!

share|improve this question
1  
Cool, a script that deletes McAfee! This the payload of your malware or something? –  ÃŁŁǫǛȉЖΦΤїҪ Sep 25 '12 at 15:06
    
LOL NO!, also seriously. malware? its a batch script man. im a sys admin. the agent is part of our EPO server but its a major pain. normally we can just run a server side upgrade and push the new client and any updates to the end user machines but in a few cases (a lot in this case sigh) i am going to have to otherwise manually strip the agent off and then clean all registry references to it before i can then reinstall the new agent and pull the updates. too much effort hence script. –  Lex Sep 25 '12 at 15:11
    
OK, you convinced me. What exact error do you get when it tries to delete it? Is it that the key was not found? Maybe you can expand the shell variables in an echo just prior to calling the delete, in order to see what %1 is? –  ÃŁŁǫǛȉЖΦΤїҪ Sep 25 '12 at 15:15
1  
Are you getting any errors? Also, put quotes around %1. A lot of those McAfee keys have spaces in them. –  Kasius Sep 25 '12 at 15:21
    
no errors, but as allquixotic said the keys have a space in them. ive actually tried adding "" marks either side of the value but it doesnt seem to parse them at all. will try it again, thanks for the assist guys –  Lex Sep 25 '12 at 16:08
show 2 more comments

1 Answer

up vote 5 down vote accepted

It looks like reg delete needs the /f at the end:

C:\TEMP>reg delete /f hkcu\test
ERROR: Invalid key name.
Type "REG DELETE /?" for usage.

C:\TEMP>reg delete hkcu\test /f
The operation completed successfully.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.