Jump to content

gcond[]


Recommended Posts

I had been working with Lawrenca on this for a few days before I figured it out. When doing a gcond[] or cond[] check for registry settings he would get the error message "....Treating as false condition....", however it goes. This method works:

gcond[pn]=['try{WshShell.regRead("HKLM\\SOFTWARE\\7-Zip\\Path") != "" ? true : false}catch(ex){;}'];

The try{} and catch{} eliminate the error message. Modify for your needs.

Link to comment
Share on other sites


I had been working with Lawrenca on this for a few days before I figured it out. When doing a gcond[] or cond[] check for registry settings he would get the error message "....Treating as false condition....", however it goes. This method works:

gcond[pn]=['try{WshShell.regRead("HKLM\\SOFTWARE\\7-Zip\\Path") != "" ? true : false}catch(ex){;}'];

The try{} and catch{} eliminate the error message. Modify for your needs.

so , if i want to check

at

$Regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows Media Player 10\KB911565"

if exist the key

$KeyToCheck = "DisplayVersion"

and if exist the $KeyToCheck, at $Regpath with a value

$KeyValueExpected = "2"

and only then my gcond must be true (i use this in an autoIT script)

you say I can use without error something like

gcond[pn]=['try{WshShell.regRead($Regpath\\$KeyToCheck) == $KeyValueExpected ? true : false}catch(ex){;}'];

or translated

gcond[pn]=['try{WshShell.regRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Updates\\Windows Media Player 10\\KB911565\\DisplayVersion") == "2" ? true : false}catch(ex){;}'];

Link to comment
Share on other sites

That's what Lawrenca is doing with it. I myself never use it. I do clean installs only so I don't need to check for any existance of installed programs.

He is doing updates to existing client computers and has already installed programs grayed out. Actually, I think he modded his code to not show the line at all. You may want to contact him for more ways he is using it.

As for no errors, I mean no errors from WPI. The eval() call would throw up this error message:

Error in condition statement for -program-: Treating as a false condition.

You can put your own error message inside the catch(ex){;} brackets if you want. As is, nothing is reported. Which is better for a UA install. If you want, put this in there:

alert("RegKey does not exists.");

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...