I've never worked with batch files before, but the idea behind this is that I want to simply run a program after I've been inactive for a certain period of time.
It doesn't matter which program, I just want it to run concurrently with my screensaver for some lighting effects with my keyboard.
I suppose another solution would be to detect whether the screensaver is running or not and start on that condition as well, I just have no idea where to begin with this one, but am willing to learn.
Asked
Active
Viewed 354 times
-1

Craseder
- 3
- 1
2 Answers
0
This powershell gets all users last long on time. Change the time variable, should work.
Import-Module ActiveDirectory
function Get-ADUsersLastLogon()
{
$dcs = Get-ADDomainController -Filter {Name -like "*"}
$users = Get-ADUser -Filter *
$time = 0
$exportFilePath = "c:\lastLogon.csv"
$columns = "name,username,datetime"
Out-File -filepath $exportFilePath -force -InputObject $columns
foreach($user in $users)
{
foreach($dc in $dcs)
{
$hostname = $dc.HostName
$currentUser = Get-ADUser $user.SamAccountName | Get-ADObject -Server $hostname -Properties lastLogon
if($currentUser.LastLogon -gt $time)
{
$time = $currentUser.LastLogon
}
}
$dt = [DateTime]::FromFileTime($time)
$row = $user.Name+","+$user.SamAccountName+","+$dt
Out-File -filepath $exportFilePath -append -noclobber -InputObject $row
$time = 0
}
}
Get-ADUsersLastLogon

user3795654
- 86
- 3
- 12
0
Just schedule a task in Task Scheduler to run only if user not used computer in last 10 mins.

Noodles
- 1,981
- 1
- 11
- 4