+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, vbs - if subkey exists then else in Coding and Web Development; I have got a vbscript that deletes registry keys from the local machine however some of the keys may/may not ...
  1. #1


    Join Date
    Sep 2009
    Posts
    565
    Thank Post
    13
    Thanked 55 Times in 34 Posts
    Rep Power
    223

    vbs - if subkey exists then else

    I have got a vbscript that deletes registry keys from the local machine however some of the keys may/may not have sub keys. I have managed to code it so that if the key has a subkey it is deleted, however if it doesn't have a subkey the script fails. My code is ugly as sin and I'd rather not post it but I will if it is needed.

    Anyone got any ideas how I can accomplish this?

    cheers

  2. #2


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 853 Times in 732 Posts
    Rep Power
    294
    if yor just want to remove a key and subkeys isnt it easier to create a reg file with a - next to the keyname and regedit/s regfile.reg (or use gpp)?

    so to remove a key

    [-HKEY_CLASSES_ROOT\Software\test]

  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    You need to check for the existence first before you run your deletion code. You would need to use on error resume next and check the error number for success. There are plenty of examples if you search for this kind of process.

SHARE:
+ Post New Thread

Similar Threads

  1. [SIMS] SIMS Nested if then Else - Colour in Blank Cells
    By LianneKemp in forum MIS Systems
    Replies: 2
    Last Post: 16th August 2013, 09:27 AM
  2. Replies: 4
    Last Post: 23rd August 2011, 03:31 PM
  3. Replies: 1
    Last Post: 5th April 2011, 05:17 PM
  4. [Powershell] IF THEN ELSE
    By box_l in forum Scripts
    Replies: 4
    Last Post: 23rd February 2011, 02:41 PM
  5. Replies: 3
    Last Post: 1st March 2006, 12:08 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •