VBScript to update registry entries
HI folks
I need a VBscript (simply .vbs extention file which i can place on server windows 2003 or windows 2008). So any user with administrative rights can just double client and run it.
First when admin user runs the script it should ask Browser value and then Client_Name value. Then entered value should be updated in registry.
It should replace any existing values in Browser and Client_Name as entered by user under HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config
It should also update logs(bascically values entred by user in log file at location C:\Temp\nbuscript
OR another way.
admin user simply put 2 values(first value Browser, second value Client_Name) in a notepad file C:\Temp\value then VBScript updates both values under location
HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config
then write logs at location C:\Temp\nbuscript
I am a newbie in vbscript so need spoonfeeding at scripting level. Any help would be much appreciated.
Answers (2)
I super suck at scripting but I would break it down to little bits then join it all together. Just to note one last time, i super suck at scripting.
*have a read of this, sometimes if it dosent work you might have forgotten to DIM the var.
http://stackoverflow.com/questions/1033507/what-does-dim-stand-for-in-visual-basic-and-basic
http://msdn.microsoft.com/en-us/library/zexdsyc0(v=vs.84).aspx
Use Notepad++, it highlights the code etc so its easier to read, it also helps with the ""escaping quotes thing.
This bit of code helps with debugging, it just spews out the value of the var, so just put in in somewhere, where you need to check the value.
WScript.Echo "strInput var value is: " & strInput
1)
Look at this, if you launch it like (shortcut) wscript.exe your_script.vbs, it will give you a nice GUI box rather than a sh*tty cmd prompt for input.
http://www.robvanderwoude.com/vbstech_ui_userinput.php
2)
From what i learned in the past, there are a few ways to write to the registry, I found a WMI object easy to use, but it tends to crap out every now and then so you need to add in error checking (to check WMI is ok, but add in error checking after you have something working).
Mod this to your needs
http://blogs.technet.com/b/heyscriptingguy/archive/2006/11/16/how-can-i-create-a-new-registry-key.aspx
There is also thise method, but I didnt use it for some reason or another
http://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.84).aspx
3)
Logging should be easy, just appending to file
Not sure if this will create the file at the start though.
http://myitforum.com/cs2/blogs/dhite/archive/2007/05/06/vbs-script-to-append-to-a-specified-text-file.aspx