Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   How to detect if registry key is defined (https://www.kinook.com/Forum/showthread.php?t=1201)

Ken 08-11-2005 12:01 AM

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

kinook 08-11-2005 08:16 AM

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")]

Ken 08-12-2005 11:48 AM

When I tried this I get the following error. Any ideas on what I am doing wrong?
-Ken



Error expanding macros in property condexpr:

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

kinook 08-12-2005 12:55 PM

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)?

Ken 08-12-2005 01:48 PM

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


All times are GMT -5. The time now is 09:20 AM.


Copyright © 1999-2023 Kinook Software, Inc.