Jump to content

Error handling for RegDelete <solved>


Recommended Posts

  • Moderators

I'm currently working on a script that deletes a number of registry keys left over from an application uninstall. I have the script working, but am wondering about a clean way to manage error handling. In some instances, a key may not exist and would therefore throw an error. I can write an IF statement, but there are over 200 keys and that would be a mess. Is there a simple way to say have the script perform a task if any of the keys is non-existant or fails to delete - something like a DO...Until without having to declare each key?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

I've not decided 100% on the action I want to take, but I'm leaning toward doing a msgbox that times out after 5 seconds or so, and then continuing. That part I have and am comfortable with, just looking at the best way to check every line without a large number of statements or having to declare every key into an array.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I was going to suggest an Array, but I don't know of another solution if that does not work for you. How else would you get what keys need to be checked? If you have the uncompiled script, just use a decent editor to do a search/replace so you do not have to key in all of the lines from scratch. I have macros set up in TextPad that allow me to add the text in the clipboard to the beginning or the end of each line. Post your code and I can help

Edited by Varian
Link to comment
Share on other sites

or having to declare every key into an array.

Don't be stupid now, you have to use either, and an array would be an infinite times easier, so why not. Infinity is a large thing you know ;)

If you simply doesn't know how to handle arrays, see the Array Tutorial in the wiki. I could write you an example, but there's something good on TV starting now. See you tomorrow.

Link to comment
Share on other sites

  • Moderators

Thanks for the offer of assistance Varian, but I believe I found a method that will work with the smallest overhead.

Never considered myself stupid Admiral, simply reaching out to those that may have more knowledge. I do know how to use the array functions, and stated my reasoning on avoiding it. I find, personally, that unnecessary nastiness in a forum is often a case of making assumptions about people you don't know - such as me, for example, believing the stereotype that all Swedish men with poor grammar are gay Posted Image - so I won't take offense to your comment. I'll be marking this as closed.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

May I ask what your soultion was?

Thanks for the offer of assistance Varian, but I believe I found a method that will work with the smallest overhead.

Never considered myself stupid Admiral, simply reaching out to those that may have more knowledge. I do know how to use the array functions, and stated my reasoning on avoiding it. I find, personally, that unnecessary nastiness in a forum is often a case of making assumptions about people you don't know - such as me, for example, believing the stereotype that all Swedish men with poor grammar are gay Posted Image - so I won't take offense to your comment. I'll be marking this as closed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...