Reputation: 11
First off, some background: I'm a student on co-op at an engineering firm, and I need to write a .bat file to close a scanning program after 5 minutes of not being use. the scanner is on a local network, and won't let anyone open the program to scan anything if someone else is using it.
So my question is whether or not there is a .bat command that can check inactivity, like measure how long it's been since someone has clicked a button, and after 5 minutes of nothing, close the program.
I've made a file that will open the program, and close it after a 5 minute timer, which will suffice for now, but I want to try to make it better. Any advice would be great! Thanks!
@echo off
cd "C:\WINDOWS\twain_32\escndv"
start escndv.exe >NUL
PING 1.1.1.1 -n 1 -w 300000 >NUL
Taskkill /im escndv.exe >NUL
echo Epson GT-20000 has been terminated due to inactivity
PAUSE
I have minimal experience with .bat files, so what I have is from a couple hours looking around on Google.
Upvotes: 1
Views: 8897
Reputation: 31221
You could try something like this:
schtasks /create /sc ONIDLE /i 5 /tn scanner /tr closescanner.bat
This will create a scheduled task to run closescanner.bat
when the pc has been idle for 5 minutes.
Just create a separate batch file called closescanner.bat
with Taskkill /im escndv.exe >NUL
inside to close the app when no-one has touched the pc for 5mins.
Hope this helps!
Upvotes: 3