Hi,
You can create a scheduled task to run your current cmd script and add a trigger "On an event" with the log off event id 4647. You need to enable the group policy setting Audit Logoff which is under Computer Configuration\Windows Settings\Security Settings\Advanced Audit Policy Configuration\System Audit Policies.
https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/audit-logoff
https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4647
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.