(Actually, more like custom data fields, but they work alike.)

I note in the documentation that the functions available in custom inventory rules (e.g., FileExists) can be combined with AND and OR operators. Which leads to these questions:
1. Can those operators be grouped using parentheses?
2. Is there an operator for NOT (or maybe !FileExists?) If not, is there a trick to testing for the non-existence of a file or directory?

Also, I'm looking to use the ShellCommandTextReturn(cmdline) function for the first time. Since this invokes cmd.exe, I assume I can write any single cmdline that works in a batch file. And since batch files can combine command lines using &, &&, ||, test logic using IF, and parse using FOR, I should be able to create a little user function, all in one line. Is this correct? Are there any limitations, like characters that ShellCommandTextReturn won't allow?

Has anyone done anything fancy like this with ShellCommandXXXReturn() that you're willing to share? Sande
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
1. Nope, there's no grouping available. They're evaluated in order, left to right. The "default grouping" looks like this, and the interpreter will short-circuit to FALSE upon encountering the first AND if the left-side group evaluates to FALSE. (...(((FUNC OP FUNC) OP FUNC) OP FUNC) OP....)
2. Nope.

ShellCommandTextReturn() doesn't like commas in the input, I believe. If you need commas, the standard suggestion is to sync down a cmd or bat file to a particular location and execute that.
Answered 09/22/2010 by: jkatkace
Purple Belt

Please log in to comment
0
Thanks for the quick answers--that's a good start.

And another question: Can environment variables (like %PROGRAMFILES% or %SystemRoot%) be used in the custom inventory rule functions? For example, FileExists(%PROGRAMFILES%\Mfr\Application\appl.exe).

Given the limitations you noted before, I can guess this answer is No, but I'll still ask: Can a function be called from within a function? For example: FileInfoReturn(EnvironmentVariableReturn(ProgramFiles)\Mfr\Application\appl.exe, FileVersion, TEXT)

Or even better: FileInfoReturn(FilenamesMatchingRegexReturn(C:\Program Files,^thisone\.exe$,TEXT),FileVersion,TEXT)

You said the ShellCommandXXXReturn functions don't like commas, so functions within functions wouldn't work for those. I'll bet they don't like parentheses () either. I'm always interested in any escape characters that might mitigate any problems. Sande
Answered 09/23/2010 by: snissen
Fourth Degree Green Belt

Please log in to comment
0
Through a KACE Kontinuing Education Session, I was able to learn a little more:

Q1. Can environment variables (like %PROGRAMFILES% or %SystemRoot%) be used in the custom inventory rule functions? For example, FileExists(%PROGRAMFILES%\Mfr\Application\appl.exe).

A1: No. This must be an absolute path. Not a bad feature request though- please send to support@kace.com

Q2. Can a function be called from within a function? For example: FileInfoReturn(EnvironmentVariableReturn(ProgramFiles)\Mfr\Application\appl.exe, FileVersion, TEXT)

Or even better: FileInfoReturn(FilenamesMatchingRegexReturn(C:\Program Files,^thisone\.exe$,TEXT),FileVersion,TEXT)

A2. No. Conditions are evaluated from left to right and can’t be “nested” like this. Not a bad feature request though- please send to support@kace.com

Q3. How do I reorder the tasks in a Kscript?
A3. This was really a trick question, because I already found the answer: you use the raw XML editor to carefully (very carefully!) cut and paste. This is how you delete a task, too, and how you move steps from one section in a task to another. Sande
Answered 10/21/2010 by: snissen
Fourth Degree Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity