0
I'm trying to schedule a script to run at logoff on Microsoft Windows 10 Home (in particular, when I select "Shut Down" with fast startup enabled). I've created a test script
C:\Windows\System32\GroupPolicy\User\Scripts\Logoff\temp_logoff.bat
with contents
echo %DATE% %TIME% >> C:\Logs\Test.txt
pause
I ran gpedit.msc
and selected the script under
Local Computer Policy > User Configuration > Windows Settings > Script (Logon/Logoff)
The script doesn't seem to be running at logoff (no lines were added to C:\Logs\Test.txt
). I've read that gpedit.msc
is supposed to write some registry entries. I found the following registry directory
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy
but there is no Scripts
subdirectory. Do I need to do something else to get this script to run?
Additional information:
Running gpresult /v
, I see
Applied Group Policy Objects
-----------------------------
Local Group Policy
...
Resultant Set Of Policies for User
-----------------------------------
...
Logoff Scripts
--------------
N/A
I also tried creating another policy for my specific user to no avail (following this).
Run gpresult or rsop.msc to check if the policy is applied. I would suggest to use Task scheduler to run such script instead - you can always see when and how the task has been run. – Hardoman – 2018-08-26T23:14:26.320
HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy doesn't contain any settings from this part of GPO. It contains only those settings specified via Administrative templates. – Hardoman – 2018-08-26T23:17:32.230
Use the Task Scheduler. It's easier. – DxTx – 2018-08-27T06:29:00.250
@Hardoman IIUC task scheduler doesn't have a logout trigger; the advice I've seen is to trigger on an undocumented system log with ID 7002, which seems fragile. – stewbasic – 2018-08-27T21:31:31.587
@Hardoman I ran gpresult as you suggested. It indicates the policy was applied but shows no logoff script. – stewbasic – 2018-08-27T22:00:49.460
@stewbasic that's absolutely normal to use event ID 7002 as a trigger. Regular practice. – Hardoman – 2018-08-28T14:41:23.847
@stewbasic if there is no logon script in the resultant policy that means: either policy is incorrectly configured, or there is another policy overriding it. Can you output policy to html file and attach it here? (gpresult /h c:\temp\res.html) – Hardoman – 2018-08-28T14:45:03.323
@Hardoman On my system gpresult doesn't seem to have a /h option. I'm starting to think that none of this works on windows home edition... I will try the task scheduler with event 7002 as you suggest. Still happy to get either a workaround or confirmation that this can't work, for future reference. – stewbasic – 2018-08-28T22:00:57.207