Skip to content

EastHell/WorkTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🕒 WorkTimer

WorkTimer is a simple PowerShell script that enforce limited sessions. It runs a 1-hour countdown timer, gives spoken and visual notifications before time runs out, and logs out the user automatically. The script is designed to be run at user login and supports Cyrillic output.


🔧 Features

  • ✅ 1-hour countdown (default)
  • 🔔 Visual + spoken alerts at customizable time thresholds
  • 🧪 Test mode for fast debugging (15s countdown)
  • 🚪 Automatic forced logoff when time is up
  • 🖥️ Fully compatible with Windows 11, using only built-in tools (PowerShell + VBScript)

📦 Files Included

WorkTimer.ps1     # Main PowerShell script with alert + logout logic
WorkTimer.vbs     # Helper VBScript to run the PowerShell script silently
README.md         # This documentation

▶️ Usage

✅ Normal mode

To start a 1-hour session:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File WorkTimer.ps1

This uses default alert thresholds: 10, 5, and 1 minute remaining.

🧪 Test mode

Quick 15s run for testing (alerts at 10s, 5s, and 1s):

powershell.exe -NoProfile -ExecutionPolicy Bypass -File WorkTimer.ps1 -Test -Verbose

In test mode:

  • Shortened countdown
  • Verbose output
  • No logout

Quck 15s run for testing with logout:

powersherll.exe -NoProfile -ExecutionPolicy Bypass -File WorkTimer.ps1 -Test -Shutdown -Verbose

🎛️ Custom thresholds

powershell.exe -File WorkTimer.ps1 -Thresholds @(900, 300, 60)

This triggers alerts at 15, 5, and 1 minute remaining.


🗣️ Notification Behavior

Each alert:

  • Shows a balloon tip via Windows Forms
  • Speaks a message using SAPI (text-to-speech)

The script supports Unicode messages (e.g. Cyrillic).


🚀 Auto-Start on User Login

To configure the script to run at user login using Task Scheduler:

  1. Copy WorkTimer.ps1 and WorkTimer.vbs to a foler, e.g. C:\Scripts\
  2. Press Win + R, type taskschd.msc
  3. Click Create Task...
  4. On the General tab:
  • Name: WorkTimer
  • Description: Logout user after 1 hour
  • When running the task, use the following user account:
    1. Click Change User or Group
    2. In Enter the object name to select (examples): type user name of user, which u want it script to work.
    3. Press Check Names
    4. Press OK
  1. On the Triggers tab:
  • Click New...
  • Begin the task: At log on
  • Select Specific user:
  • Choose user account as you did before
  • Click OK
  1. On the Actions tab:
  • Click New...
  • Action: Start a program
  • Program/script: wscript.exe
  • Add arguments: C:\Scripts\WorkTimer.vbs
  • Click OK
  1. Click OK to save the task

This setup ensures the script runs silently via the .vbs wrapper each time user logs in.


⚠️ Permissions & Execution Policy

You may need to allow script execution:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

If the script was downloaded:

Unblock-File -Path WorkTimer.ps1

Or just bypass execution policy for this script:

powershell.exe -ExecutionPolicy Bypass -File WorkTimer.ps1

🧰 Advanced: VBScript Wrapper (WorkTimer.vbs)

The included WorkTimer.vbs allows you to launch the PowerShell script silently (no terminal window):

Set shell = CreateObject("WScript.Shell")
shell.Run "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Scripts\WorkTimer.ps1", 0

Useful for auto-start without interrupting the user.


💡 This is not high level all cases prepared script. Just thing I use by myself.


📜 License

MIT License. Use it, tweak it, improve it.

About

Parental control timer which logout user after 1h

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published