Hub You
#1 in Business Subscribe Email Print

You are here: Home > Computers and Technology > Personal Tech > VBScript – Working with the Windows Registry

Tags

  • nextdelete
  • strvaluedelete
  • string
  • strvaluedelete string
  • userstrkeypathstrvaluenameset binary
  • wscriptecho strvaluename

  • Links

  • Why You Should Encourage Your Kids to Play Soccer
  • The Zone Diet and the 40/30/30 Approach!
  • Getting Your Oats - Increase Energy and Libido Naturally
  • Hub You - VBScript – Working with the Windows Registry

    Close the Performance Gap
    One of the most difficult and emotionally draining situations you face as business owners or executives is employees not meeting your expectations. How can you handle it if they are not keeping up their end of the employee contract?Begin by taking a look at your team. Do you have the right people? Before you hire someone, think about the culture of your company, the team that you already have in place and your particular style of management. If you have a very structured environment, then you’ll want to hire people who can fit in to your more disciplined atmosphere. If you have a very entrepreneurial company then you’ll want people wh

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,

    Dog Trainer To The Stars
    Imagine having a calm and obedient dog. He doesn't yelp at every little noise or bite you forcefully because he "thinks" you're playing with him. He's also friendly, but respectful and can basically understand what he needs to do each day. Oh, the sheer bliss of it all! Now imagine that you were able to bestow this excellent behavior upon your beloved pet and those of countless others each day. That's what Tyson Kilmer does. For a living. For celebrities.Tyson, 37, has had a love for animals ever since the day he was born. It's no wonder he has immersed himself in an animal career. Growing up on a farm, this celebrity dog trainer learned how to sp
    The script below demonstrates the write, read and deletion for each type of value in the Windows registry.

    The registry value types are:

    • String (REG_SZ): A fixed-length text string.
    • Binary (REG_BINARY): Raw binary data. Most hardware component information is stored as binary data and is displayed in Registry Editor in hexadecimal format.
    • DWORD (REG_DWORD): Data represented by a number that is 4 bytes long (a 32-bit integer). Many parameters for device drivers and services are this type and are displayed in Registry Editor in binary, hexadecimal, or decimal format.
    • Multi-String (REG_MULTI_SZ): A multiple string. Values that contain lists or multiple values in a form that people can read are generally this type. Entries are separated by spaces, commas, or other marks.
    • Expandable String (REG_EXPAND_SZ): A variable-length data string. This data type includes variables that are resolved when a program or service uses the data.

    Option Explicit

    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_USERS = &H80000003
    Const HKEY_CURRENT_CONFIG = &H80000005

    Dim strComputer
    Dim objRegistry
    Dim strKeyPath
    Dim strValueName
    Dim strValue
    Dim arrValues
    Dim intValue

    strComputer = "."

    Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootdefault:StdRegProv")

    'Create Key
    strKeyPath = "Registry Test"
    objRegistry.CreateKey HKEY_CURRENT_USER,strKeyPath

    'Set String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    strValue = "123"
    objRegistry.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

    'Get String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    Wscript.Echo strValueName & " = " & strValue

    'Delete String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    arrValues = Array(1,2,3,4,5,6,7,8,9,10)
    objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,

    Fancy A Change Of Career - Why Not Try Carbon Coaching
    What is a carbon coach?In July 2005 I left a near perfect job, Director of a successful consultancy (ABS consulting) to set up in business as The Carbon Coach. My mission (and it is mission possible!) is to coach celebs and influential individuals: to help them prosper and feel good by shrinking their lifestyle carbon footprint for real (the tonnage of carbon dioxide emissions that their households travel and energy is responsible for.) I hold their hand while they change a (energy efficient) light bulb!How does it work?I aim to rapidly raise peoples awareness of their direct carbon impacts on the environment. The people I coach a
    >Multi-String (REG_MULTI_SZ): A multiple string. Values that contain lists or multiple values in a form that people can read are generally this type. Entries are separated by spaces, commas, or other marks.
  • Expandable String (REG_EXPAND_SZ): A variable-length data string. This data type includes variables that are resolved when a program or service uses the data.

  • Option Explicit

    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_USERS = &H80000003
    Const HKEY_CURRENT_CONFIG = &H80000005

    Dim strComputer
    Dim objRegistry
    Dim strKeyPath
    Dim strValueName
    Dim strValue
    Dim arrValues
    Dim intValue

    strComputer = "."

    Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootdefault:StdRegProv")

    'Create Key
    strKeyPath = "Registry Test"
    objRegistry.CreateKey HKEY_CURRENT_USER,strKeyPath

    'Set String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    strValue = "123"
    objRegistry.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

    'Get String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    Wscript.Echo strValueName & " = " & strValue

    'Delete String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    arrValues = Array(1,2,3,4,5,6,7,8,9,10)
    objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,

    Building Trust For Lifetime Success
    Trust.One word.One very powerful word that can increase both first time and repeat sales to an unlimited degree.Trust.What is it? Why is it so important? How do you get it?Confidence in you from your cutomers, builds relationships and as a result, more sales, and through excellent customer service.That's the short and sweet of it.Now, how about a little more meat to it.What is trust and why is it so important?Definition: confidence in a person or thing because of the qualities one perceives or seems to perceive in him or it. (Webster's)The confidence that any visitor or potential custo
    000005

    Dim strComputer
    Dim objRegistry
    Dim strKeyPath
    Dim strValueName
    Dim strValue
    Dim arrValues
    Dim intValue

    strComputer = "."

    Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootdefault:StdRegProv")

    'Create Key
    strKeyPath = "Registry Test"
    objRegistry.CreateKey HKEY_CURRENT_USER,strKeyPath

    'Set String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    strValue = "123"
    objRegistry.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

    'Get String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    Wscript.Echo strValueName & " = " & strValue

    'Delete String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    arrValues = Array(1,2,3,4,5,6,7,8,9,10)
    objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,

    Google Shakes Up The Internet Marketing World
    Well, you knew this was going to happen. With the recent YouTube buyout, you had to know that Google was up to something. Sure enough, they were. Recently Google announced that they were going to change their search engine ranking system to give more weight to sites that contained video. What does this mean for Internet marketers? It means a whole new way of thinking about putting your site and sales pitch together. In this article, I'm going to go over just a few things that you're going to need to do in order to keep up with the new world that we're about to live in.For one thing, it's now going to be very difficult to compete with sites that ha
    'Get String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    Wscript.Echo strValueName & " = " & strValue

    'Delete String value
    strKeyPath = "Registry Test"
    strValueName = "String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    arrValues = Array(1,2,3,4,5,6,7,8,9,10)
    objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,

    Discover the Advantages to Hiring a Freelance Web Site Copywriter for Your Web Business
    Web Marketing SeriesOk…so you already have a crack staff of writers on-hand to handle your company website's writing assignments. So why should you consider hiring a freelance copywriter?Well, as you know, today’s corporate belt-tightening often means too much work for too few people. This is especially true in the communications area, where cutbacks have strained the resources of our workforce across the board. The result? Stress, overwork and low morale.And of course, this strain is more intense when those unusual or special projects come up. The disruption in the day-to-day activities of your staff can have two results. Either th

    'Get Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Binary value
    strKeyPath = "Registry Test"
    strValueName = "Binary Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    intValue = 123
    objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,intValue

    'Get DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    objRegistry.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,intValue
    Wscript.Echo strValueName & " = " & intValue

    'Delete DWORD value
    strKeyPath = "Registry Test"
    strValueName = "DWORD Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Multi-String value
    strKeyPath = "Registry Test"
    strValueName = "Multi-String Test"
    arrValues = Array("Test1","Test2","Test3")
    objRegistry.SetMultiStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues

    'Get Multi-String value
    strKeyPath = "Registry Test"
    strValueName = "Multi-String Test"
    objRegistry.GetMultiStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
    For Each strValue In arrValues
    Wscript.Echo strValueName & " = " & strValue
    Next

    'Delete Multi-String value
    strKeyPath = "Registry Test"
    strValueName = "Multi-String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Set Expandable String value
    strKeyPath = "Registry Test"
    strValueName = "Expandable String Test"
    strValue = "123"
    objRegistry.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    'Get Expandable String value
    strKeyPath = "Registry Test"
    strValueName = "Expandable String Test"
    objRegistry.GetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    Wscript.Echo strValueName & " = " & strValue

    'Delete Expandable String value
    strKeyPath = "Registry Test"
    strValueName = "Expandable String Test"
    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName

    'Delete Key
    strKeyPath = "Registry Test"
    objRegistry.DeleteKey HKEY_CURRENT_USER,strKeyPath

    Set objRegistry = Nothing

    Please note:

    The above script write, read and delete values in the HKCU hive but can easily be modified to write to any of the registry hives.

    The deletion function is the same no matter what value type is being deleted

    HTTP = HTML link (for blogs, profiles,phorums):
    <a href="http://www.iadvice.info/article/176532/iadvice-VBScript--Working-with-the-Windows-Registry.html">VBScript – Working with the Windows Registry</a>

    BB link (for phorums):
    [url=http://www.iadvice.info/article/176532/iadvice-VBScript--Working-with-the-Windows-Registry.html]VBScript – Working with the Windows Registry[/url]

    Related Articles:

    How To Improve Project Delivery Through Good Business Requirements

    Affiliate Marketing- Information On Affiliate Content Sites-Blogs

    Debt Management Centers Can Help You Get Out of Debt

    Bookmark it: del.icio.us digg.com reddit.com netvouz.com google.com yahoo.com technorati.com furl.net bloglines.com socialdust.com ma.gnolia.com newsvine.com slashdot.org simpy.com shadows.com blinklist.com