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

20 comments:

coupon code said...

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

Robert 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

kathita said...

Thank you

Santosh said...

Thanks! Finally found reliable vb script to read registry.

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.

Anonymous said...

reuse trial versions of software http://freshoemsoftware.com/es/category-9/product-27667/McAfee-Foundstone-Enterprise-6-8 cabinet designing software [url=http://downloadoemsoftware.us/oem-software/altova-authentic-enterprise-2010-12.0.html]altova authentic enterprise 2010 12.0[/url]
Macromedia ColdFusion MX 7.0 Standard http://freshoemsoftware.com/it/category-100-107/product-13281/Autodesk-MAP-3D-2007 cingular blackjack software [url=http://freshoemsoftware.com/category-8/product-29934/Iceni-Technology-InfixPro-PDF-Editor-4-0]TradingSolutions 3.0[/url]
free animation softwares http://freshoemsoftware.com/es/category-100-104/product-24983/DIGIEFFECTS-AURORIX-WIN32-2-14-FOR-AE Source Insight 5.2 [url=http://goldoemsoftware.com/legal-software/cakewalk-project5-%28soft-synth-workstation%29.html]cakewalk project5 %28soft synth workstation%29[/url]
game burning free software http://freshoemsoftware.com/it/category-4/product-26525/Red-Giant-Magic-Bullet-Looks-1-2-for-Adobe-After-Effects flashcards software pda [url=http://freshoemsoftware.com/fr/category-12/product-29920/Xlinksoft-Youtube-to-iPhone-Converter-2009]free trial voicemail software[/url]
epson print cd software http://freshoemsoftware.com/product-17495/CoffeeCup-Direct-FTP-6-2 QuadriSpace Document3D Suite 2008 SP0.7 [url=http://freshoemsoftware.com/de/category-10/product-13686/Becky-Internet-Mail-2-44-00]Becky Internet Mail 2 44 00[/url]
free firewall virus software http://freshoemsoftware.com/fr/category-9/product-16672/Tiny-Firewall-2005-Professional-6-5 live set music software [url=http://freshoemsoftware.com/es/manufacturer-1/product-15101/Corel-Home-Office-5-0-Multilingual]prining software[/url]

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...


Really had to mention I am just delighted that i happened on your web page. i SUCK i KNOW

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!