Action relevance subsitiution problem

(imported topic written by Bjowah91)

Dear all,

I’m trying to create a simple form of uninstaller. It is just intended to kick of the uninstaller for a program.

But the thing is I don’t get the relevance subistution for the parameter query to work properly. If I exchange the “{parameter “sKeyword” of action}}” command to a string like “skype” this works. Can anyone help me find the relevance error I would appreciate it a lot.

Best regards

Björn

Action script:

action parameter query “sKeyword” with description "Please enter a keyword from the display name of key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall: "

wait {(value “uninstallstring” of it as string as lowercase) of keys whose (value “displayname” of it as string as lowercase contains “{parameter “sKeyword” of action}}”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}

(imported comment written by wnolan91)

I would count your “}” in both directions… looks like you are missing one or have an extra. Bill

(imported comment written by SystemAdmin)

I think it needs to look like this:

wait “{(value “uninstallstring” of it as string as lowercase) of keys whose (value “displayname” of it as string as lowercase contains (parameter “sKeyword” of action)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}”

(imported comment written by Bjowah91)

Hi,

I tried all your suggested relevance code but without luck. If you lock in the documentation the extra } is needed when you have a relevance substitution inside another relevance substitution.

Maybe the parameter query command is special.

Any further assistance would be appreciated

/Björn

(imported comment written by jessewk)

what value are inputing into the action parameter dialog (sKeyword)?

(imported comment written by Bjowah91)

hi, jessewk

sKeyword is a string from the parameter query command for example “skype” or “google earth”

Thanks

/Björn

(imported comment written by jessewk)

Ah, I think I see the problem.

You are passing plural results to the wait command. That won’t work. Even if there is only a single returned value, because you are using a plural construction you’ll get an error.

Try this instead:

wait “{(it as string as lowercase) of value “uninstallstring” of key whose (value “displayname” of it as string as lowercase contains (parameter “sKeyword” of action)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}”

However, the above will have the opposite behavior… it will fail when there is more than one display name that contains the sKeyword variable. But that is probably the behavior you want anyway… if there’s more than one match you’ll want to provide a query so you don’t accidentally remove the wrong product.

Jesse

(imported comment written by Bjowah91)

Hi Jessewk

I did not get that to work either.

I wounder what the difference could be since the relevance works if I try it with a fixed string like “skype”

I exchange this

wait {(value “uninstallstring” of it as string as lowercase) of keys whose (value “displayname” of it as string as lowercase contains “{parameter “sKeyword” of action}}”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry

To this:

wait {(value “uninstallstring” of it as string as lowercase) of keys whose (value “displayname” of it as string as lowercase contains “skype”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry

then it is working…

I really would look forward to see an action code debugger in BES 7…

/björn

(imported comment written by brolly3391)

Hey Bjowah,

It is a common error when I teach the action script part of the Custom Content class to try to use relevance substitution inside of relevance substitution. This is what Tyler was pointing out to you in his post above.

wait {some relevance}

The part inside of the curly brackets will be evaluated as relevance and the result substituted into the action script.

wait {some relevance {some other relevance} }

The inner {} characters are redundant and cause an error because you are already in relevance because of the outer {}. You might want to trade out those internal curly braces {} for parenthesis ().

wait {some relevance (some other relevance) }

I hope that I have explained that clearly. Now let’s apply that to your action script.

wait {(value “uninstallstring” of it as string as lowercase) of key whose (value “displayname” of it as string as lowercase contains (parameter “sKeyword” of action)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}

Now, if there is more than one registry key that meets the relevance, then you have a plural result trying to go into the wait command, which also fails. This is what Jesse was pointing out. The best way to handle that, assuming that you want all the programs that meet your relevance to be uninstalled, is to build a .BAT file with the appendfile command and then run the .BAT file. This works because appendfile will handle plural results by adding a line for each result into the file.

delete __appendfile
appendfile {(value “uninstallstring” of it as string as lowercase) of keys whose (value “displayname” of it as string as lowercase contains (parameter “sKeyword” of action)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}
delete temp.bat
copy __appendfile temp.bat
wait temp.bat
delete temp.bat

Additional note: Sometimes you need to put a curly brace into relevance that will be in an action script, such as if you need to have a GUID as part of a registry key. You can use these hex substitutions; “%7b” for { and “%7d” for } when this becomes necessary. This is not the case in the issue above; I just wanted you to be aware.

And finally, we have been asking for an action script debugger for as long as I have been using BigFix - 3 years now. It is not likely. There are security context issues. The best way to debug your actions is to use a custom action and paste your action script in and let a real client on a test box run your script.

Cheers,

Brolly

(imported comment written by Bjowah91)

Hi,

Thank you brolly for your explanation, that sorts a lot out when it comes to relevance substitution.

The .bat file version of the script work really well.

Thanks everyone how contributed on this issue.

/Björn

(imported comment written by rdamours91)

Just checking to see if I can borrow another set of eyeballs on this one

action parameter query “Server Name” with description “Please enter your target server name eg. Main-XXX” and with default value “”

wait “{pathname of system folder & “\msiexec”}” /i “{(pathname of client folder of current site) & “__Download\Notebook Software.msi”}” ISX_SERIALNUM=“NB-AEDSG-BAN5W-AFMZZ-2ACSB” FULL_GALLERY=1 LAT_CONTENT=1 NETWORK_CONTENT=1 CONTENT_TARGET_PATH="\" & “{parameter “Server Name” of action}” & “\STUDAPPS$\SMARTGALLERY” ACTIVATE_LICENSE=1 /Q

(imported comment written by BenKus)

Try this:

wait “{pathname of system folder & “\msiexec”}” /i “{(pathname of client folder of current site) & “__Download\Notebook Software.msi”}” ISX_SERIALNUM=“NB-AEDSG-BAN5W-AFMZZ-2ACSB” FULL_GALLERY=1 LAT_CONTENT=1 NETWORK_CONTENT=1 CONTENT_TARGET_PATH="{parameter “Server Name” of action}\STUDAPPS$\SMARTGALLERY" ACTIVATE_LICENSE=1 /Q

Ben

(imported comment written by rdamours91)

Once again Ben is the man…

I’ll play with it again later to determine if they entered in only main- or main-2k as part of the prompt process.

Eg. Main-xxx or main-2k-xxx

I’ve tried every variation of braces, parentheses, and double quotation marks (including %22) I can think of and cannot make this work :disappointed_relieved:

Trying to get “C:\PDE-v27\Server.msi”

action uses wow64 redirection {not x64 of operating system}

parameter "Version" = "27"

wait cmd /c "{(pathname of it) of file whose (name of it ends with "Server.msi") of folder (%22C:\PDE-v%22&{parameter "Version" of action})}"

Thanks in advance!

Normally I’d discourage resurrecting a ten-year-old thread, but you get bonus points for code-tagging your actionscript :slight_smile:

You can’t nest curlybrackets inside of curlybrackets, and you don’t need ‘%22’ unless the doublequote is literally part of a string…try

wait cmd /c "{pathname of file whose (name of it ends with "Server.msi") of folder ("C:\PDE-v" & parameter "Version" of action)}"

Thank you sir - and even more so for the explanation! (Worked like a charm, naturally.)

I’ve been avoiding creating duplicate threads but am not well versed in forum etiquette, would it be more appropriate to start a new one after a certain number of years?

Thanks again

Glad to help!

Unless your post is very closely related to the old thread, it’s generally better to start a new thread. All the original posters on the old thread may get an email when you reply to it, you’ll get better responses on a new thread, and folks (like me) who are reading from a phone have to do a lot of scrolling to make it down to your post.

If you’re posting something directly related to the old thread, like “something changed and this info isn’t correct anymore” or a question like “does this old setting still apply today” then of course that’s worth bringing the older thread back into discussion.

1 Like