I recently created a task to cleanup old Microsoft Malicious Removal Tool (MRT) EXE from Windows. It works by checking file dates and deleting from Windows and BigFix and if BigFix is recent, copy back to Windows.
This part of the code, seems to have no issues.
// Force 64bit
action uses wow64 redirection false
// Kill any running process
if {exists running application "mrt.exe"}
WAITHIDDEN "taskkill /F /IM mrt.exe"
endif
if {exists running application "Windows-KB890830.exe"}
WAITHIDDEN "taskkill /F /IM Windows-KB890830.exe"
endif
// Delete older MRT from Windows System folder
if {exists file "MRT.exe" whose (modification time of it < (now - 45 * day)) of native system folder}
delete "{native system folder}\MRT.EXE"
endif
In one of our deployments (I did not check others), 742 computers ran this fine. However, 20 failed at the same place with this section:
// Delete older MRT from BigFix Client folder
if {exists file "Windows-KB890830.exe" whose (modification time of it < (now - 45 * day)) of folder (pathname of parent folder of client folder of site "actionsite" as string & "\__MSTools\RemovalTool")}
delete "{pathname of parent folder of client folder of site "actionsite"}\__MSTools\RemovalTool\Windows-KB890830.exe"
endif
Client logs show:
Wow64 redirection disabled. action uses wow64 redirection false (group:1126590,action:1126629)
Command succeeded delete "C:\windows\system32\MRT.EXE" (group:1126590,action:1126629)
Command failed (Relevance substitution error.) if {exists file "Windows-KB890830.exe" whose (modification time of it < (now - 45 * day)) of folder (pathname of parent folder of client folder of site "actionsite" as string & "\__MSTools\RemovalTool")} (group:1126590,action:1126629)
If I run the relevance in QNA, these computers have no issues. True/False is returned correctly. All endpoints are Windows Servers (12/16/19/22).
Any ideas what could be issue?
And for those curious about the full task, this is the last part.
// Copy Windows-KB890830.exe to MRT.exe
if {exists file "Windows-KB890830.exe" of folder (pathname of parent folder of client folder of site "actionsite" as string & "\__MSTools\RemovalTool")}
copy "{pathname of parent folder of client folder of site "actionsite"}\__MSTools\RemovalTool\Windows-KB890830.exe" "{native system folder}\MRT.EXE"
endif
More frustrating is the relevance for the task, has the same code essentially. Which means the computer already interpreted it fine. Itâs just when being used as substitution in actionscript.
(version of client >= "6.0.0.0") AND ((exists true whose (if true then (exists (if exists true whose (if true then in proxy agent context else false) then "Proxy - " & data source else "Native") whose (it as string as lowercase contains "Native" as lowercase)) else false)) AND (exists true whose (if true then (exists (operating system) whose (it as string as lowercase contains "Win" as lowercase)) else false)) AND (exists true whose (if true then ((exists file "MRT.exe" whose (modification time of it < (now - 45 * day)) of native system folder) OR (exists file "Windows-KB890830.exe" whose (modification time of it < (now - 45 * day)) of folder (pathname of parent folder of client folder of site "actionsite" as string & "\__MSTools\RemovalTool") | False)) else false)))
Screenshot showing False as the file is recent, but then True when I change 45day to 1day.