Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-11-2005, 12:01 AM
Ken Ken is online now
Registered User
 
Join Date: 05-08-2003
Posts: 20
How to detect if registry key is defined

I need to determine if a registry key is defined before I use it. If it's not defined, then I have to define it.

How do I go about detecting if a registry value is defined?

Ken
Reply With Quote
  #2  
Old 08-11-2005, 08:16 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Use this in a Run Script step (VBScript):

Function RegValueExists(key)

Set objSh = CreateObject("WScript.Shell")

On Error Resume Next
objSh.RegRead(key)

RegValueExists = (Err = 0)

End Function

Builder.LogMessage RegValueExists("HKCU\Control Panel\Opened")

or put the function in project/global scripts and reference in a step field like

[RegValueExists("HKCU\Control Panel\Opened")]
Reply With Quote
  #3  
Old 08-12-2005, 11:48 AM
Ken Ken is online now
Registered User
 
Join Date: 05-08-2003
Posts: 20
When I tried this I get the following error. Any ideas on what I am doing wrong?
-Ken



Error expanding macros in property condexpr: <Error at Line 1, Column 1 (Type mismatch: 'RegValueExists')>

The code I am using for the conditional execution is --

[RegValueExists("HKEY_LOCAL_MACHINE\SOFTWARE\Kinook Software\Visual Build Professional\Last Successful Build\%Project% %Unit%")]


The code from my global script is ----

Function RegValueExists(key)

Set objSh = CreateObject("WScript.Shell")

On Error Resume Next
objSh.RegRead(key)

RegValueExists = (Err = 0)

End Function
Reply With Quote
  #4  
Old 08-12-2005, 12:55 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Based on the error message, it appears that the RegValueExists function is undefined. Did you add it to project or global scripts (View | Script Editor | Project/Global tab)?
Reply With Quote
  #5  
Old 08-12-2005, 01:48 PM
Ken Ken is online now
Registered User
 
Join Date: 05-08-2003
Posts: 20
Thumbs up

OK, I see my mistake. I had placed it in the "Global Subroutines Steps" tabs and not the folder you told me. This fixed it! Thanks.

Ken
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 08:55 PM.


Copyright © 1999-2023 Kinook Software, Inc.