I have written a fixlet to do a file search and append it to a file. It works on some endpoints, and others it return the following error
Command failed (Relevance substitution failed ) appendfile {concatenation “%0d%0a” of (it as string) of (pathname of it & " (" & (size of it / 1000) as string & " KB)") of descendants whose (name of it contains “.bat”) of folder “c:”}
Here is a short list of the fixlet, with the DIR .bat the only one that fails occasionally.
appendfile ******************************
appendfile ********** DIR .BAT **********
appendfile ******************************
appendfile {concatenation “%0d%0a” of (it as string) of (pathname of it & " (" & (size of it / 1000) as string & " KB)") of descendants whose (name of it contains “.bat”) of folder “c:”}
appendfile ******************************
appendfile ********** DIR TEMP **********
appendfile ******************************
appendfile {concatenation “%0d%0a” of (it as string) of (pathname of it & " (" & (size of it / 1000) as string & " KB)") of descendants of folder “temp” of windows folder}
appendfile **********************************
appendfile ********** DIR System32 **********
appendfile **********************************
appendfile {concatenation “%0d%0a” of (it as string) of (pathname of it & " (" & (size of it / 1000) as string & " KB)") of descendants of system folder}
If this is a case where it runs into an error, how do I get it to continue and just put a blurb that says, could not find or something like that.
Testing this out on my system, I would get this error only when I changed the “of folder “c:”” to point to a directory that did not exist. One thing I am wondering about is what the agent is using as the working directory. I am wondering if a change of the “c:” to “c:” might help.
Another way might be to first output the files you are looking for to a file and then read from that file. Something like this:
============================================================
waithidden cmd.exe /c dir /b /s c:*.bat > c:\temp\files.log
waithidden cmd.exe /c dir /b /s {windows folder}\temp >> c:\temp\files.log
waithidden cmd.exe /c dir /b /s {system folder} >> c:\temp\files.log
delete __appendfile
appendfile {(pathname of it & " (" & (size of it/1024) as string & " KB)%0d%0a") of files (it of lines of file “c:\temp\files.log”)}