RegRead / RegWrite VBS

Written by James McDonald

June 5, 2013

Thinking of storing settings in registry. Some sample code:

set oshell = createobject("wscript.shell")

apf = "HKEY_LOCAL_MACHINE\SOFTWARE\Settings"
settings = Array("user", "domain", "password", "host")
slug = apf & "\edi_transfer_"

' create APFoods key 
oshell.regwrite "HKLM\SOFTWARE\APFoods\" , "", "REG_SZ"

' create values
oshell.regwrite "HKLM\SOFTWARE\APFoods\edi_transfer_user" , _
				"username", _
				"REG_SZ"
oshell.regwrite "HKLM\SOFTWARE\APFoods\edi_transfer_domain" , _
				"domainname", _
				"REG_SZ"
oshell.regwrite "HKLM\SOFTWARE\APFoods\edi_transfer_password" , _
				"secret_password", _
				"REG_SZ"
oshell.regwrite "HKLM\SOFTWARE\APFoods\edi_transfer_host" , _
				"remote_host", _
				"REG_SZ"

set d = createobject("Scripting.Dictionary")

for each i in settings

		d.add i , oshell.regread(slug & i)

next

for each j in d.items

	wscript.echo j

next

for each k in d.keys

	wscript.echo d.item(k)

next

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...