I'm trying to delete a registry key on windows during uninstall. When running

reg.exe delete "HKEY_LOCAL_MACHINE\SOFTWARE\test" /f

in a script/batch command, reg.exe reports that it cannot find the key, while the key is deleted OK if I run the command by hand.

Any ideas would be highly appreciated!

Is there another way to remove a registry key? (The key needs to be removed completely, not just the value changed).