windowsscriptingregistrylogoff

Windows 7 Logoff script


I need to add log off script on windows. I can do it through gpedit.msc, but i need to automate it via scripts.

I find lot of registry keys examples, but no one works.

E.g : http://www.jhouseconsulting.com/2008/08/26/scripting-updates-to-the-gptini-for-the-local-group-policy-39 Or https://social.technet.microsoft.com/Forums/windows/en-US/5c0d7e87-6dec-4f87-8ef2-f43b4064d4d5/execution-of-a-script-at-every-logoff-of-any-user?forum=w7itprosecurity

No one works.

Do you have any solutions, which is tested and works for you?

Thanks.


Solution

  • When you use GPEDIT for creation of those entries it creates the policy in

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Logoff
    

    as it is explained in one of your links. However when I try this there are a lot more entries created than the few described in the technet thread, so the first thing to do is, create the entry manually, go there, export everything and re-import on another computer.

    If this doesn't work I would scrap the whole registry idea and realize it via the task scheduler. Create a task with a trigger on the logoff event of any user in the gui (might need to enable additional auditing depending on which events you really need), export it to xml and re-import it using

    schtasks /Create /XML <xmlfile> /TN <taskname>