Need help creating a Task Scheduler definition


pokeefe0001

Well-known member
Member
VIP
Local time
3:53 AM
Posts
217
Location
Pacific Northwest USA
OS
Windows 11
I'm trying to do something that appears to be a bit beyond me: issue a command (or run a batch file) whenever a user loses access to the computer. By "loses access" I mean:
  1. the computer enters a low power state
  2. the user logs out
  3. the user locks the screen
  4. the user switches to a different userid (which I think is the same as logging out)
  5. a remote desktop connection is terminated
  6. anything else that I haven't thought of
I need trigger #1 above to run the command the command prior to the computer going to sleep, not when it wakes from sleep later on. I know that Kernel-Power Event-id 42 is created for entering sleep, but I fear that event may happen too late to trigger the task. Is Event-id 187 a reasonable alternate?

For #3 I can find no logged event record. I've seen mention of a Security Event-id 4800, but that doesn't seem to be created on my computers. Is that just for AD environments? (Every thing I've read about it sort of implies AD.) Is there any way to detect a Lock event if no event record is created?

Before I start tackling the Bitlocker part of this project I'd like some way to just log the fact that the my scheduled task executed. Is there some way for a batch file to create a Windows notification or a user-created event record?
 
Windows Build/Version
Win 11 Pro x64 22000.1219

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
Instead of answering your questions, maybe it's best to explain what goal is driving this project. Maybe the correct answer is entirely different from your desired solution.

eventcreate or PowerShell's Write-EventLog can write events for you.
 

My Computer

System One

  • OS
    Windows 7
I currently use VeraCrypt and have a VeraCrypt container (sort of similar to a an encrypted .vhd file) on a NAS. I can access this one at a time - from 5 computers (in theory; from 3 in practice). I don't always remember to dismount the file when I am done and this blocks access from the other computers.

VeraCrypt had options to dismount the file when the user logs off, when a screen saver is launched, when a user session is locked, when the computer enters power saving mode, and when no data has been written or read for a user-specified time period. Great in theory, but that capability stopped working (for me) a couple years ago. (Nobody else has reported this publicly and the VeraCrypt community has not responded to my questions about this.)

I tried creating scheduled task with (I thought) some of the triggers mention above but it did not work. The script itself does work so I assume I've not succeeded in defining the task correctly. I'm probably completely missing something in the trigger definition, but I don't know.

Along the way I thought I would try this with Bitlocker instead of VeraCrypt - just because I could get questions answered about Bitlocker.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort

Latest Support Threads

Back
Top Bottom