• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

Looking for way to log out of Windows when Firefox is closed

I'm setting up some training computers running on Windows 7 Pro, I'll be using Firefox with Site Block Plus, and Public Fox

One thing I'd like to add is that when a user closes Firefox, they get logged out of Windows as well.

Any thoughts?
1 Solution
Esteban BlancoPresidentCommented:
You could write a log off script that runs as a scheduled task when the users closes firefox.exe *32

Just a thought.
ITDharamAuthor Commented:
Sounds reasonable, can you expand on that?  I've never setup a task that is based on a running process.
you could use powershell to do this:

have a startup script that launches firefox and then logs the user out when it is closed:

$firefox = "c:\program files\firefox\firefox.exe" #replace with your working path
$process = start-process $firefox -passthru

}while(get-process -id $process.id)
shutdown /L

Open in new window

That's a nice script except it has a "busy loop" in it.

You could use VBScript and a WMI Asynchronous query that watches for process deletion.

Or a much easier variation of the same method can be done using PowerShell 2 and its Register-WMIEvent cmdlet.

Either method would use a WQL query for an "__InstanceDeletionEvent" of a "Win32_Process".

Here's a simple PowerShell example:
$wql = "SELECT * FROM __InstanceDeletionEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process' and TargetInstance.Name='firefox.exe'"

Register-WmiEvent -Query $wql -Action { Write-Host "Firefox closed." }

Open in new window

ITDharamAuthor Commented:
Works a charm!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now