Loop with EnumRegValue only partially works
I have a bunch of laptops with pre-configured software that are being retasked. They are non-networked machines so using a GPO type deployment will not work for my application. I am creating an installer with specific software that will be used for deployment, but these laptops each have between 12-17 entries set to run on startup. Bad bad bad!
I wrote the following into my installer, but when it runs it only gets a half dozen or so then jumps out. I intend to log the installation and would like to detail each of the removed entries from the Run key, otherwise I would just brute-force it and use DelRegKey and then make a new, empty one.
; Remove everything from the startup menu and the Run registry keyAm I missing something here? Why will it not cycle through all of the values in the Run key?
StrCpy$0 0 ; initialize a loop counter
loop:
ClearErrors
EnumRegValue$1 HKLM "Software\Microsoft\Windows\CurrentVersion\Run" $0
IfErrors RunDone ; if nothing is set to run, then jump out
DetailPrint"Removed from startup: $1" ; print what software is set to autostart
DeleteRegValue HKLM"Software\Microsoft\Windows\CurrentVersion\Run" $1 ; delete the registry entry so it doesnt run automatically
IntOp$0 $0 + 1 ; increment the loop counter
Goto loop
RunDone: