Solved

Check for Registry VALUE in script

Posted on 2006-10-20
5
434 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

13 Experts available now in Live!

Get 1:1 Help Now