Solved

Search and replace registry value via VBScript

Posted on 2010-08-12
3
856 Views
Last Modified: 2012-08-13
Search registry for below value via VBScript
"HKEY_CURRENT_USER\Software\Juniper Networks\Network Connect 6.3.0\dsNetworkConnect\logoffonConnect" if DWord is 1

then replace the below Value Dword to 1 or else do nothing

"HKEY_CURRENT_USER\Software\Juniper Networks\Network Connect 6.5.0\dsNetworkConnect\logoffonConnect"
0
Comment
Question by:khalsa70
  • 2
3 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 33421953
something like this:

check this: http://ezinearticles.com/?VBScript---Working-with-the-Windows-Registry&id=305615
Const HKEY_CURRENT_USER = &H80000001

Dim objRegistry

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



dim rs

dim rr

dim rv

dim st



rs = "Software\Juniper Networks\Network Connect 6.3.0\dsNetworkConnect"

rr = "Software\Juniper Networks\Network Connect 6.5.0\dsNetworkConnect"

st = "logoffonConnect"



objRegistry.GetStringValue HKEY_CURRENT_USER,rs,st,rv

if rv=1 then 

  objRegistry.SetStringValue HKEY_CURRENT_USER,rv,st,1

end if

Open in new window

0
 

Author Comment

by:khalsa70
ID: 33423102
Getting a error with this script. Cannot figure out the issue
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 33423467
here is a working sample

I have

HK\Test\
A : SZ
B : DWord

under HKEY_CURRENT_USER
Const HKEY_CURRENT_USER = &H80000001



Dim objRegistry

dim strComputer

strComputer = "."



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



dim rs

dim rr

dim rv

dim st



rs = "HK\Test"

rr = "HK\Test"

str = "B" 'dword value

sts = "A" 'string value



objRegistry.GetDWORDValue HKEY_CURRENT_USER,rs,str,rv

WScript.Echo "B = " & rv



if rv=1 then 

  objRegistry.SetStringValue HKEY_CURRENT_USER,rs,sts,"HK"

  WScript.Echo "set HK"

else

  objRegistry.SetStringValue HKEY_CURRENT_USER,rs,sts,"HainKurt"

  WScript.Echo "set HainKurt"

end if

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA additional condition 2 61
How to debug this code 7 56
Index Match Vlook up for a master file 7 58
Protecting vb6 & .Net code Obfuscation 18 94
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now