Tuesday, July 10, 2007

VBScript - Read From Registry

Here is a quick and dirty function for reading a registry value using the WScript.Shell object:

    function readFromRegistry (strRegistryKey, strDefault )
  • Dim WSHShell, value

  • On Error Resume Next

  • Set WSHShell = CreateObject("WScript.Shell")

  • value = WSHShell.RegRead( strRegistryKey )


  • if err.number <> 0 then

  • readFromRegistry= strDefault

  • else

  • readFromRegistry=value

  • end if


  • set WSHShell = nothing

  • end function

Usage:
    str = readfromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\ESD\Install_Dir", "ha")
    wscript.echo "returned " & str

17 comments:

Anonymous said...

as a tech geek your entry on .net is of tremendous value to my programmer buddies

Unknown said...

Thank-you very much. I spent 3 hours tying to figure out how to see which sound card is the default device in vbscript. This post led me to the answer. Thank-you

anonymous said...

Thank you

Santosh Pathak said...

Thanks! Finally found reliable vb script to read registry.

Anonymous said...

hong kong travel agents http://icej.eu/house/del-oro-house-cupertino petra travel tours [url=http://icej.eu/kitchen/italian-kitchen-table]italian kitchen table[/url]
travel organizations for young women http://icej.eu/decoration/santa-clause-ferris-wheel-lawn-decoration csonka pocket travel ashtray [url=http://icej.eu/kitchen/old-style-nu-tone-kitchen-exhaust-fan]fromer travel books[/url]
heidelberg travel http://icej.eu/sunrooms/cost-of-sunrooms shreveport to las vegas travel package [url=http://icej.eu/floor/discount-wood-floor]discount wood floor[/url]
emergency travel services http://icej.eu/bathroom/bathroom-renovation-in-burlington-ontario eurotek travel system [url=http://icej.eu/concrete/mark-brady-concrete]no reservations travel channel[/url]
travel vaccine and diabetes http://icej.eu/decoration director travel chair personalized [url=http://icej.eu/landscaping/landscaping-geraniums]landscaping geraniums[/url]
latest travel book releases http://icej.eu/room/isaiah-throne-room-of-yahwh premier travel inn dundee west [url=http://icej.eu/home/phoenix-home-estate-real-36th-route-scottsdale-add-listings-stop]nomad travel trailer[/url]

Anonymous said...

Finally blog with beneficial informations.

www.e3d.es said...

I read a lot of helpful info in this post!

Anonymous said...

Thank you! This helped much!

Anonymous said...

If you are going for finest contents like I do, only visit this site everyday since
it presents feature contents, thanks
Here is my web page ; www.teenpornpost.com

Anonymous said...

Why people still use to read news papers when in this technological globe
the whole thing is existing on web?
Feel free to visit my blog free porn picture

Anonymous said...

I know this if off topic but I'm looking into starting my own blog and was wondering what all is required to get setup? I'm assuming having a blog like yours would cost a pretty
penny? I'm not very internet savvy so I'm not 100% positive. Any suggestions or advice would be greatly appreciated. Thank you
Check out my web blog drunk nude girls

Anonymous said...

I'm really impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days.
Here is my homepage - nc esc

Anonymous said...

Hi there! This post could not be written any better!
Looking through this post reminds me of my previous roommate!
He continually kept preaching about this.
I'll send this article to him. Fairly certain he's going to have a very
good read. Thank you for sharing!

Also visit my webpage :: hakukonemainonta

Anonymous said...

I'm no longer positive where you are getting your info, however good topic. I must spend some time learning much more or understanding more. Thanks for wonderful information I used to be looking for this info for my mission.

Here is my web page; facebook quotes
My site :: life quotes

Anonymous said...

Why visitors still use to read news papers when in this technological globe everything is accessible on net?


Also visit my web-site ... Arabic Books

Anonymous said...

Thanks for one's marvelous posting! I seriously enjoyed reading it, you happen to be a great author.I will make sure to bookmark your blog and definitely will come back in the foreseeable future. I want to encourage you to continue your great posts, have a nice holiday weekend!

Stop by my blog post :: http://www.cuteteenporn.net

Klopstmeister said...

Don't know about anyone else but I had to put a "\" at the end of the key and change value = WSHShell.RegRead( strRegistryKey & strDefault )

To get it to work.

Thanks for the FUNCTION!