[gptalk] Re: Registry Logic Statement

  • From: "Paul Williams" <paul.williams@xxxxxxxxxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Mon, 4 Dec 2006 13:41:42 -0000

Answers inline...


----- Original Message ----- From: <dcnash@xxxxxxxxxxxxx>
To: <gptalk@xxxxxxxxxxxxx>
Sent: Friday, December 01, 2006 3:30 PM
Subject: [gptalk] Re: Registry Logic Statement


I have never written vbscript before so this is a new venture for me. Might you be kind enough to give me a crash course breakdown of how I would write this code? I started reading up on it, but MS website doesnt explain things very well. I just need it in plain words, i.e. what is the purpose of a "declaration". I need a quick rundown of code. I found a sample code, if you could just run throught it real quick and tell me what each function does and why, it will help me out a great deal. Thank you for your time and effort, the code is:

Option Explicit

This is forcing you to decalre your variants.


Dim objShell
Dim strCachedLogon, strShell, strPwdWarn, strWinLogon

Variant declarations. Required because of option explicit. Simply defining the variants that will be used. Think of these as portions of memory that you can store values in.


strPwdWarn = "passwordexpirywarning"
strShell = "Shell"
strCachedLogon ="cachedlogonscount"
strWinLogon = "HKLM\SOFTWARE\Microsoft\"_
& "Windows NT\currentVersion\Winlogon\"

Here you are assigning values to your variants.


Set objShell = CreateObject("WScript.Shell")

Instantiating an Windows Shell object. This object allows you to use Windows system variables, read the registry, etc.


strShell = objShell.RegRead(strWinLogon & strShell)
strPwdWarn = objShell.RegRead(strWinLogon & strPwdWarn)
strCachedLogon = objShell.RegRead(strWinLogon & strCachedLogon)

Assign the values of registry keys to variants.


Wscript.Echo "Shell Program " & vbTab & strShell & vbCr _
& "Password Expires " & vbTab & strPwdWarn & vbCr _
& "Cached Logons " & vbTab & strCachedLogon

Output the values read from the registry.


WScript.Quit

Exit script.

' End of Registry Example VBscript.

DC Nash


From: Jeremy Saunders <jeremy.saunders@xxxxxxxxxxx>
Date: 2006/12/01 Fri AM 03:01:41 EST
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: Registry Logic Statement

Yep, that's how I would do it...or if you want it in a VBScript, then use
the RegRead function.

--------------------------------------------------
strRegKey = "HKCU\Environment\"
strValue= "Temp"
Set objShell = CreateObject("WScript.Shell")
strValueData = objShell.RegRead(strRegKey & strValue)
Wscript.Echo "The TEMP environment variable is set to: " & strValueData
--------------------------------------------------

Cheers.

 Kind regards,

 Jeremy Saunders
 Senior Technical Specialist

 Infrastructure Technology Services
 (ITS) & Cerulean
 Global Technology Services (GTS)
 IBM Australia
 Level 2, 1060 Hay Street
 West Perth  WA  6005

 Visit us at
 http://www.ibm.com/services/au/its

 P:  +61 8 9261 8412                F:  +61 8 9261 8486
 M:  TBA                            E-mail:
                                    jeremy.saunders@xxxxxxxxxxx











             "Jeremy Waldrop"
             <jwaldrop@cookcon
sultingservices.c To
             om>                       <gptalk@xxxxxxxxxxxxx>
Sent by: cc
             gptalk-bounce@fre
elists.org Subject
                                       [gptalk] Re: Registry Logic
                                       Statement
             01/12/2006 07:27
             AM


             Please respond to
             gptalk@freelists.
                    org






Use reg.exe with the query command.

Reg query

-----Original Message-----
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx]
On Behalf Of dcnash@xxxxxxxxxxxxx
Sent: Thursday, November 30, 2006 4:28 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Registry Logic Statement

Does anyone know of a way to create a logic statement that checks the
presence of a value in the registry?
My goal is to check a specific value in the registry, if the value is
there, do nothing. If its not there then run a program to add the entry.
Ive tried to create an adm to solve this issue, but the value is a
binary value. To my knowledge you cant write a binary value to the
registry using .adm files. Any ideas would be appreciated! BTW I found a
VBScript that does what I need it to do, however it creates an error if
the value is already present, I need it to be invisible to the users on
our network.

Thanks,

DC Nash

***********************
You can unsubscribe from gptalk by sending email to
gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR
by logging into the freelists.org Web interface. Archives for the list
are available at //www.freelists.org/archives/gptalk/
************************
***********************
You can unsubscribe from gptalk by sending email to
gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by
logging into the freelists.org Web interface. Archives for the list are
available at //www.freelists.org/archives/gptalk/
************************


***********************
You can unsubscribe from gptalk by sending email to gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by logging into the freelists.org Web interface. Archives for the list are available at //www.freelists.org/archives/gptalk/
************************


***********************
You can unsubscribe from gptalk by sending email to gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by logging into the freelists.org Web interface. Archives for the list are available at //www.freelists.org/archives/gptalk/ ************************

***********************
You can unsubscribe from gptalk by sending email to 
gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by 
logging into the freelists.org Web interface. Archives for the list are 
available at //www.freelists.org/archives/gptalk/
************************

Other related posts: