1.

Solve : Batch file auto answer?

Answer»

I am trying to make a batch file using the "reg" command which edits entries in the registry. Specifically, I want to automatically delete a SPECIFIC registry entry every time a program boots up. The only problem is that the "reg" command requires you to confirm the deletion of the entry (considering it's a registry entry it's understandable). I also checked the "help" part of the "reg" command, there doesn't seem to be any flag to force the deletion.

So my question is: is there anyway to make an "auto answer" in the batch file so that "Y" is entered in everytime the confirmation comes up?

Thanks. I did a brief search of the FORUM and wiki, and didn't see any answer to this question, sorry if it's been asked before.

OS: WINDOWS XP Corporate Edition.

Specifically the commad is:

Reg delete HKLM\Software\Classes\CLSID\{7E1B4139-3E2A-53A1-62C2-2E973AD18F8B}\MiscStatus /v data

which deletes the "data" value under that folder.
There is probably no way to do it because you risk damaging your computer. That's kind of presumptuous of the coders then since there are many other commands that could damage your computer which allow /y parameters to say "yes" to all, suchas "deltree", this can damage your computer if you delete the wrong tree.

Although this is a bit off the subject, I don't think coders of commands should presume the level of expertise of the person using the command, while it is good to have a failsafe such as a confirmation, if a person is sure that he wants to do something, let him do it, if he damages his computer, then he damages his computer, he chose to use the /y function knowing full well what it does.
Ummm ..., why does this particular registry key keep getting added back to the registry? Quote from: soybean on September 09, 2007, 08:53:04 PM

Ummm ..., why does this particular registry key keep getting added back to the registry?

Please, do not take this as being rude, but does that matter? I know that I want to delete this registry value and I know what it does. My only question is not about the registry value and how or why it is added, but whether or not the "reg" command can have an autoanswer in the PARAMETER field to get through the confirmation.

I would think that it would be a lot easier too just leave the confirmation box activated then cahnging it because there are many risks involvedNot for nothing, yes it is true that playing around with the registry can be dangerous, but that is why you can easily export any key with the simple click of the mouse button. Also, I don't think there should be this divine mystry about the sensitivity of registry values, some registry values simply disable the screensaver, some autoexecute a file on startup, some remove the trash can from your desktop, and so? That's what they do, people who know what they're doing, well, know what they're doing.

If you don't know what you're doing and don't back up a registry key, then, well, that's your fault, and you sort of ask for what happens to your computer. But the fact of the matter, some people do know what they need to do, and I think it is presumptuous for the coders of command lines to think otherwise. Just putting a simple /y option isn't turing off the failsafe for those who may not be sure of whether to delete something or not, but to NOT give the option for experienced users on the assumption that "it is dangerous" is just silly imo.
just do an echo
Code: [Select]C:\test>echo Y | reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ /v test

Delete the registry value test (Y/N)?
The operation completed successfully
Quote from: ghostdog74 on September 09, 2007, 09:27:15 PM
just do an echo
Code: [Select]C:\test>echo Y | reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ /v test

Delete the registry value test (Y/N)?
The operation completed successfully

Thank you very much ghostdog74 that was the simple answer I was looking for and it worked as well.

Also I found this PAGE:

http://www.windowsitpro.com/Article/ArticleID/14741/14741.html

which says:

Quote
Would delete the HKEY_LOCAL_MACHINE\Software\test value. When you enter the command you will be prompted if you really want to delete, enter Y. To avoid the confirmation add /force to the command, e.g.

reg delete HKLM\Software\test /force

However, I tried using that syntax using "/force" and it didn't work. In any event, the echo worked, thanks ghostdog.


Discussion

No Comment Found