I created a task which runs in the background waiting for WhatsApp to run. If WhatsApp is opened, it creates a log file giving details about the user and version, and creates a registry entry that can be searched with an analysis. I have attempted to run this as a policy, so it will log each time WhatsApp is opened up, but it doesn’t seem to operate as I thought it should. The task goes to a “completed” state, and doesn’t re-run.
Below is the task. Is there a better way to do this that I’m overlooking? Could/Should this be done using PowerShell? I’m open to any and all suggestions!
Thanks!
//Waiting for WhatsApp to run
pause while {not exists running application whose (it as string as lowercase contains “whatsapp”)}
if {exists file “__createfile”}
delete __createfile
endif
if {exists file “WhatsApp.txt”}
delete WhatsApp.txt
endif
//Setting the registry key to be True for WhatsApp
setting “BannedApps\WhatsApp”=“1” on “{parameter “action issue date” of action}” for client
//Creating reg file to set the version and name within the registry.
Createfile until end-reg-edit-commands
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BigFix\EnterpriseClient\Settings\Client\BannedApps\WhatsApp]
“DisplayVersion”=“{version of running application whose (it as string as lowercase contains “whatsapp”)}”
“DisplayName”=“{name of running application whose (it as string as lowercase contains “whatsapp”)}”
end-reg-edit-commands
move __createfile setup.reg
wait regedit /s setup.reg
//Checking for existing log file, if exists, copies current data and appends new data
if {exists file “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”}
createfile until WhatsAppUpdate
{lines of file “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”}
–WhatsApp ran on {parameter “action issue date” of action} by {name of current user}. WhatsApp version is {version of running application whose (it as string as lowercase contains “whatsapp”)}. The WhatsApp executable is located at “{location of running application whose (it as string as lowercase contains “whatsapp”)}”.
WhatsAppUpdate
copy __createfile WhatsApp.txt
delete “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”
copy WhatsApp.txt “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”
endif
//Checking for existing log file, if not, creating the log file
if {not exists file “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”}
createfile until newfile
–WhatsApp ran on {parameter “action issue date” of action} by {name of current user}. WhatsApp version is {version of running application whose (it as string as lowercase contains “whatsapp”)}. The WhatsApp executable is located at “{location of running application whose (it as string as lowercase contains “whatsapp”)}”.
newfile
copy __createfile WhatsApp.txt
if {not exists folder “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps”}
folder create “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps”
endif
copy WhatsApp.txt “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Custom\BannedApps\WhatsApp.txt”
endif
if {exists file “setup.reg”}
delete setup.reg
endif
pause while {exists running application whose (it as string as lowercase contains “whatsapp”)}