Solved

Check for Registry VALUE in script

Posted on 2006-10-20
5
438 Views
Last Modified: 2008-02-12
I want to use a log on script to check for a registry VALUE.  The key may or may not exist.  if the key exists it can have two values- 1, and 2.  

i want the script to change the value to 2 if it's currently 1 but not to do anything if the key doesn't exist.  

Is that possible?

I know you can look for the KEY by using:
If exist [HKEY_LOCAL_MACHINE\rest of key]

but how do I make the script look for the value?

thanks in advance.


0
Comment
Question by:jmerulla
  • 2
5 Comments
 
LVL 6

Expert Comment

by:SCDMETA
ID: 17776726
Option Explicit

Dim WSHShell, RegKey, Value

Set WSHShell = CreateObject("WScript.Shell")

RegKey = "HKLM\Software\Company\Test"


On Error Resume Next

' read key
Value  = WSHShell.RegRead(RegKey)
if Err.Number = 0 Then
      
      WScript.echo "Value: " & Value

      if Value = 1 Then
            ' write key
            WshShell.RegWrite RegKey & "test", 2
      end if

      ' read key again
      Value  = WSHShell.RegRead(RegKey & "Test")
      WScript.echo "Value: " & Value
Else
      WScript.echo "Not Found"
End If
0
 
LVL 2

Author Comment

by:jmerulla
ID: 17776796
i saw that, but I'm trying to do this in a logon script.  I'm not exactly sure how to use it.  Can you please explain?

thanks
0
 
LVL 6

Accepted Solution

by:
SCDMETA earned 250 total points
ID: 17777674
http://www.computerperformance.co.uk/Logon/logon_script_assign.htm

Check out the bottom of this article.
It explains using Group Policy and the aritcle has some pretty good examples.
http://www.tek-tips.com/faqs.cfm?fid=5798



0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

820 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