Delete File Relevance Substitution failing due to Space Charachter in File Path

I am attempting to delete a file from our workstations using a BigFix Task. I am debugging my relevance in the QnA app using the Action tab.

My relevance is as follows:
if {exists file “_Utils.zip” of folder (“C:\Users” & (name of current user as string) & “\AppData\Local\BigFix\Enterprise Console\FQDN” & (name of current user as string) & “@DOMAIN\Sites\CustomSite_Availity_Windows_Servers”)}
delete {“C:\Users” & (name of current user as string) & “\AppData\Local\BigFix\Enterprise Console\FQDN” & (name of current user as string) & “@DOMAIN\Sites\CustomSite_Availity_Windows_Servers_Utils.zip”}

Looking at the Client log I get:
"STATUS: Running action…
Command succeeded delete No ‘C:\Users\nbrown\AppData\Local\BigFix\Enterprise’ exists to delete, no failure reported

— Result —
Evaluation completed successfully!"

It is obviously terminating the string at “”\AppData\Local\BigFix\Enterprise Console\FQDN"", But I cannot get the relevance substitution to treat the space in the file path as a literal. Is there anything I can do to remediate this?

You are not enclosing the path in quotes, so it is being cut off at the first space.

Also, you shouldn’t have to delete this file this way, and infact if you do, it should get put back by the console if it is still a valid site file. If you remove the file from the site, then it should remove it from all console caches EVENTUALLY, but you really need to remove the file from the site first.


Also, generally the better way to write the relevance is to inspect ALL users folders for the file you wish to delete, then get the first result, then delete it, like:

folders "Sites" of folders of folders of folders "AppData\Local\BigFix\Enterprise Console" of folders of folders "C:\Users"

It doesn’t matter if there is only ever a single user that has the console on a system, regardless it is easiest to do it this way.

Hey Stew,

Thank you for the speedy reply. I did delete the file from the site but unfortunately it has some unapproved software in it that we need to delete as soon as possible. Enclosing the file path in single quotes returns a new error of

“Command failed (Relevance substitution failed) delete {“C:\Users” & (name of current user as string) & ‘\AppData\Local\BigFix\Enterprise Console\redacted’ & (name of current user as string) & “redacted\Sites\CustomSite_Availity_Windows_Servers_Utils.zip”}”

I’m pretty new to the platform and relevance in general so its taking some getting use to.

So for relevance, in a fixlet that did this would be like:

exists files "FILE_NAME.zip" of folders "CustomSite_CUSTOM-SITE-NAME" of folders "Sites" of folders of folders of folders "AppData\Local\BigFix\Enterprise Console" of folders of folders "C:\Users"

Then for the action to delete it:

delete "{ tuple string items 0 of concatenations ", " of pathnames of files "FILE_NAME.zip" of folders "CustomSite_CUSTOM-SITE-NAME" of folders "Sites" of folders of folders of folders "AppData\Local\BigFix\Enterprise Console" of folders of folders "C:\Users" }"


Also, it is a rather bad idea to distribute a large file as a site file. It should instead be placed in the root server’s uploads folder and then prefetched to the clients that way.

Sites should be as small as absolutely possible. Any site files that are distributed to clients should be very tiny, ideally under 10MB.

Sweet,

Appreciate the feedback. Going to test this out and then reply back.

If you dont mind, can you explain the "{ tuple string items 0 of concatenations “, " of pathnames of files” portion of the action here. Would you not be able to delete the file by doing:

“delete “FILE_NAME.zip” of folders “CustomSite_CUSTOM-SITE-NAME” of folders “Sites” of folders of folders of folders “AppData\Local\BigFix\Enterprise Console” of folders of folders “C:\Users” }”

1 Like

This is a very good question, and it is not obvious.

The actionscript delete command can only delete a single file. If multiple paths were provided, it would not work.

Consider a case where multiple files on the system match the relevance: (which is possible in this case)

Q: tuple string items 0 of concatenations ", " of ("FilePath1";"FilePath2")
A: FilePath1
T: 0.058 ms
I: plural string

It is a best practice in general in relevance to always write it plural as if multiple results are possible, because it results in better relevance that is less likely to fail, but in this case we must force a single answer regardless of how many file paths match the relevance. What tuple string items 0 of concatenations ", " of does is take an arbitrary number of strings returned as a result of the relevance to the right and it picks the first string every time. This will work as long as the strings do not contain , within them. If they did happen to contain that, then there is an alternative method.

Another option is the following:

Q: (preceding text of firsts "-TOKEN-" of it | it) of concatenations "-TOKEN-" of ("FilePath1";"FilePath2")
A: FilePath1
T: 0.069 ms
I: plural string

In a case where multiple files match the relevance, the actionscript would delete the first one, but then it would still be relevant afterwards and you would just have to run it again and again until all matching files are deleted. If the success criteria is set to “original relevance becomes non relevant” or whatever that is called, then it would report failure if multiple files are present, even though it should have succeeded in deleting one of them. To properly handle this case, you actually have to set the number of files to be deleted in a parameter and then have the success criteria be custom relevance in which the number of files remaining is less than the number of files at the start.


Another option is to force a singular result such that it will only attempt to delete the file if there is only a single match, otherwise it will give a relevance substitution error, like this:

delete "{ unique value of pathnames of files "FILE_NAME.zip" of folders "CustomSite_CUSTOM-SITE-NAME" of folders "Sites" of folders of folders of folders "AppData\Local\BigFix\Enterprise Console" of folders of folders "C:\Users" }"

This way we keep the relevance plural until the very end, but then we force a singular result, otherwise we throw an error and do nothing. (intentionally) This is not my preferred method.


In order to delete multiple files in a single action, you have to do something else, like these examples:

These examples are better in some ways, but they are also not cross platform because they use OS specific delete commands, which is a bummer.

Reference:

3 Likes