🕒 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:
- Copy
WorkTimer.ps1andWorkTimer.vbsto a foler, e.g.C:\Scripts\ - Press
Win + R, typetaskschd.msc - Click Create Task...
- On the General tab:
- Name:
WorkTimer - Description:
Logout user after 1 hour - When running the task, use the following user account:
- Click Change User or Group
- In Enter the object name to select (examples): type user name of user, which u want it script to work.
- Press Check Names
- Press OK
- On the Triggers tab:
- Click New...
- Begin the task: At log on
- Select Specific user:
- Choose user account as you did before
- Click OK
- On the Actions tab:
- Click New...
- Action: Start a program
- Program/script:
wscript.exe - Add arguments:
C:\Scripts\WorkTimer.vbs - Click OK
- 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.
0 commit comments