Windows 10 Coming Soon
Tips & Tricks
Windows Forum
Course Index
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Windows Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Forced Sign Out
Donald Blackwell 
        
10 months ago
Any suggestions for the best method for signing a user out after x-time inactive?

Co-pilot crashes every time I ask and google just comes up with ads...

Here is the scenario: (Win11 x 64 - Home)

At the hall, there is a "common" computer that has a generic user account for each unit plus a couple of specific accounts for users that need to have files that are somewhat password protected. The generic accounts don't use passwords, the only reason for them is to keep files separated so someone from one unit doesn't delete or overwrite a file for another.

The problem is that when they get done using the computer, typically just for email, web, word, pdfs, or excel, they just get up and walk away without signing out. They don't close their programs out, etc.

Then next user gets on, wakes the computer from sleep and clicks to login. No problem, except all the applications for the other user(s) are still running or holding swap file space and after awhile, the computer slows to a crawl and then I get forced to go in and log everyone out manually.

Any help/suggestions would be appreciated as I've done little to no scripting for Windows itself.

Thanks, Don
Richard Rost  @Reply  
          
10 months ago
Yeah, I'm thinking you'd need something in the task scheduler to run a log off script after a certain number of minutes of idle activity. I asked ChatGPT about it, and here's what I came up with, which is pretty close to what I would have said anyways.

---

This is a common issue in shared-use environments, and you're on the right track thinking about idle-time detection followed by forced sign-out. Since you're using Windows 11 Home, you don't have access to Group Policy or domain tools like you'd get with Pro or Enterprise, but we can still work with PowerShell and the Task Scheduler.

Here's a reliable and lightweight solution that doesn't require third-party software:

---

Option: Use Task Scheduler + PowerShell script to sign out users after X minutes of inactivity

Step 1: Create a PowerShell script to log out the user

Create a file called `ForceLogoff.ps1` with this content:

Codeshutdown.exe /l


That's it. `/l` is the switch for logoff.

---

Step 2: Create an idle-triggered scheduled task

Since Windows doesn't have built-in "idle timeout" for sign-out in Home edition, we'll use Task Scheduler's "On idle" trigger.

1. Open Task Scheduler
2. Create a new Basic Task
3. Give it a name like AutoLogoutIdle
4. Choose When a specific event is logged (skip this, we'll edit it later)
5. Finish the wizard, then right-click the task and go to Properties
6. Under Triggers, delete the default one and click New\...

   * Begin the task: On idle
7. Under Actions, set it to Start a program

   * Program/script: `powershell.exe`
   * Add arguments: `-ExecutionPolicy Bypass -File "C:\Path\To\ForceLogoff.ps1"`
8. Under Conditions, make sure:

   * Start the task only if the computer is idle for: X minutes
   * Adjust wait time as needed
9. Under Settings, check:

   * Stop the task if it runs longer than: 1 hour
   * If the task is already running, then the following rule applies: Stop the existing instance

---

Note: You'll need to set ExecutionPolicy to `Bypass` or sign the script if running with restricted settings.

---

Alternate: Use a custom PowerShell script to track idle time

If you want more control, you can use a PowerShell script that runs in the background and checks for idle time, like this:

CodeAdd-Type @"
using System;
using System.Runtime.InteropServices;
public class IdleTime {
    [DllImport("user32.dll")]
    public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
    [StructLayout(LayoutKind.Sequential)]
    public struct LASTINPUTINFO {
        public uint cbSize;
        public uint dwTime;
    }
    public static uint GetIdleTime() {
        LASTINPUTINFO lii = new LASTINPUTINFO();
        lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));
        GetLastInputInfo(ref lii);
        return ((uint)Environment.TickCount - lii.dwTime);
    }
}
"@

$MaxIdleMinutes = 15
while ($true) {
    $idleTime = [IdleTime]::GetIdleTime() / 1000 / 60
    if ($idleTime -ge $MaxIdleMinutes) {
        shutdown.exe /l
    }
    Start-Sleep -Seconds 60
}


This runs in a loop, checks for idle time, and logs out after 15 minutes of inactivity. You can run this at startup via Task Scheduler or a shortcut in the user's Startup folder.

---

Final tips:

* This works best if users don't have unsaved work, or you want to force the habit of saving and signing out.
* If you want a friendlier experience, instead of logging out, you could lock the screen or display a warning first.
Donald Blackwell OP  @Reply  
        
10 months ago
I'll put it to the test when I'm there tomorrow.

Will be 1 more thing ticked off my list of requests there since I just spent 2-days rewiring cat-6 because the genius electrician decided to run 12/2 wiring through the same conduit/holes the cat-6 was running through... 500-meg fiber internet was reaching a max 2.5 megs because the electric lines were putting "noise" across the low-voltage lines

As always, thanks for the shared wisdom!

Don
Richard Rost  @Reply  
          
10 months ago
Haha yeah. Doing it with Access is easy. :)
Donald Blackwell OP  @Reply  
        
10 months ago
Yeah, unfortunately on that station, there are currently no databases. It's a basic system for the folks the know everything (except how to logout, use the printer, type... lol)

I started many years ago building a database to replace the financial/bookkeeping/payroll system because it is no longer supported - the developer retired about 10 or so years ago. I think the last formal update he did was around 2000... It's a 16-bit RBase for DOS application with very little win32 compatibility let alone 64-bit. Has to have a printer connected to a parallel port print checks or reports, those kinds of issues. Every time a Windows update comes through (just about) I have to go in and reset some windows settings to keep it running.

I had started developing an app BEFORE I found Richard's lessons on YouTube (and eventually this site) and had some stuff working but that was before I learned any VBA so everything was coded with macros that I figured out by winging it. Needless to say poor code and even worse editing, lol.

When I get that app done, it will connect to the other stations as well, but until then...
Matt Hall  @Reply  
          
10 months ago
Well, there was room in there for the 12/2...  :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Windows Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/1/2026 10:45:00 PM. PLT: 1s