I apologize in advance for what I'm about to ask. Our dedicated scripter in the office just got laid off and somehow I got tasked with a project involving VBScript, of which I know nothing about.
I'll provide screenshots of what I want to ultimately do, to try to help with the verbiage.
Generic Goal: I'm trying to make a script that will query the registry for a specific value under a specific string. If that value exists, I need to add new reg value under that string.
Reason: When Blackberry Device Manager is installed, it automatically creates a new modem called "Standard Modem". In order to get an AT&T Blackberry to tether to a laptop, a string has to be entered under the Standard Modem's properties; as shown here:
In the Registry, the modems appear here: On the left side, you see the "0000" subkey. If there are multiple modems installed, be it multiple aircards or whatnot, there will be multiple subkeys; "0000", "0001", "0002", "0003", etc. for however modems are installed. Since there is only 1 modem installed on the machine I screenshotted, it only shows "0000". So if there are 4 modems installed on the machine prior to installing the Blackberry Device Manager... after it is installed "Standard Modem" will be the "0004" subkey.
What I'm trying to do, is create a script that will query each registry subkey until it finds "Standard Modem" by matching the "FriendlyName". Once it finds "Standard Modem" it will write a new reg value to that subkey; as shown here: See the "UserInit" value?
This is the code I have so far; but like I said, I'm not sure if all those arguments are valid or if the syntax is correct.
When I run it though, it just sits at the command prompt. I assume it's just endless looping. I took some C++ courses in College, so I get the jist of what I'm looking at, even though its another language. Any advice? Thanks!
I'll provide screenshots of what I want to ultimately do, to try to help with the verbiage.
Generic Goal: I'm trying to make a script that will query the registry for a specific value under a specific string. If that value exists, I need to add new reg value under that string.
Reason: When Blackberry Device Manager is installed, it automatically creates a new modem called "Standard Modem". In order to get an AT&T Blackberry to tether to a laptop, a string has to be entered under the Standard Modem's properties; as shown here:
In the Registry, the modems appear here: On the left side, you see the "0000" subkey. If there are multiple modems installed, be it multiple aircards or whatnot, there will be multiple subkeys; "0000", "0001", "0002", "0003", etc. for however modems are installed. Since there is only 1 modem installed on the machine I screenshotted, it only shows "0000". So if there are 4 modems installed on the machine prior to installing the Blackberry Device Manager... after it is installed "Standard Modem" will be the "0004" subkey.
What I'm trying to do, is create a script that will query each registry subkey until it finds "Standard Modem" by matching the "FriendlyName". Once it finds "Standard Modem" it will write a new reg value to that subkey; as shown here: See the "UserInit" value?
This is the code I have so far; but like I said, I'm not sure if all those arguments are valid or if the syntax is correct.
Code:
'Variable Declaration
Option Explicit
Dim oReg, strKeyPath1, strValueName1, strValue1
Dim oReg, strKeyPath2, strValueName2, strValue2
Const HKCU = &H80000001
Const HKLM = &H80000002
'Suppresses Errors
On Error Resume Next
'Sets up connection to registry
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv")
set strSubKey1 = "0000"
set strKeyPath1 = "SYSTEM\ControlSet001\Control\Class\{4D36E96D-E325-11CE-BFC1-08002BE10318}\"
set strValueName1 = "FriendlyName"
'Start of script
oReg.GetStringValue HKLM, strKeyPath1 & strSubKey1, strValueName1, strValue1
While strValue1 <> "Standard Modem"
strSubKey1 = strSubKey1 + 1
oReg.GetStringValue HKLM, strKeyPath1 & strSubKey1, strValueName1, strValue1
Wend
oReg.SetStringValue HKLM, strKeyPath1 & strSubKey1, "UserInit", "AT+CGDCONT=2,\"IP\",\"wap.cingular\""
'EOF
When I run it though, it just sits at the command prompt. I assume it's just endless looping. I took some C++ courses in College, so I get the jist of what I'm looking at, even though its another language. Any advice? Thanks!