Solved

Check for Registry VALUE in script

Posted on 2006-10-20
5
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

740 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