Need a way to open an application and then automatically close after some time.

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
There is an app that I want users to use but it should auto close after 30 seconds or so after they finish
Is there a way to do this via batch files, etc?

Thanks! ^_^
 

Fardringle

Diamond Member
Oct 23, 2000
9,200
765
126
How could a separate program know when the users are done using this application? For that matter, how would the application itself know that the users are finished and aren't simply idle (or doing something else) for 30 seconds?

If you are having an issue where your users are not closing a program when they should, I recommend implementing a policy similar to what we use at my office. We use an office management program that locks client files open when the program is open so that those files cannot be backed up, even using shadow copies. The files remain locked if the program is forced to close by Task Manager or anything similar.

Some users frequently "forgot" to close it so the boss decided to make it policy that if someone does not close the program when they leave for the night (causing the backup to fail) they have to put a quarter in a jar. Those quarters are added to the budget to buy snacks at the weekly office meeting for everyone who did not have to "donate" that week. Quarters don't really buy much, of course, but it's enough to help people remember to close the program. People still forgot frequently for a while, but there have been very few failed backups lately. ;)


In short, don't try to solve a personnel/training problem with software...
 

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
Hey thanks a lot for your input.

The app is a timecard so they don't need more than 30 seconds to use it.
They leave it open and it causes problems. We've tried training but it isn't cutting it.
besides, there are a lot of people (80) who need to use it.

I wish I could work in a place that was as laid back about breaking backups to just require a quarter ;-)
IMO that's TOO lax.

So knowing the nature of the app, is there a way to make it auto close after opening it 120 seconds or so later?

Thanks!
 

yinan

Golden Member
Jan 12, 2007
1,801
2
71
You could do this with a vbs script.
Basically it would launch the app
Sleep 30 seconds
Kill app via either WMI or the taskkill command.

Relatively simple script.
 

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
You could do this with a vbs script.
Basically it would launch the app
Sleep 30 seconds
Kill app via either WMI or the taskkill command.

Relatively simple script.


sounds like what I want.
Can you give me an example, please. Like with calculator. Idea is to plug in the directory of the app I want to run -- which is actually a shortcut to an application on a network drive...
 

yinan

Golden Member
Jan 12, 2007
1,801
2
71
Set objShell = CreateObject("Wscript.Shell")
cmd = "calc"
objShell.Run cmd
Sleep 30000

cmd="taskkill /IM calc.exe /F"
objShell.Run cmd
 

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
Set objShell = CreateObject("Wscript.Shell")
cmd = "calc"
objShell.Run cmd
Sleep 30000

cmd="taskkill /IM calc.exe /F"
objShell.Run cmd


Many thanks!

This is the syntax that worked for me:
Code:
Set objShell = CreateObject("Wscript.Shell")
cmd = "C:\TEST.lnk"
objShell.Run cmd
WScript.Sleep 30000
cmd="taskkill /IM TEST.exe /F"
objShell.Run cmd

:thumbsup:
 
Last edited:

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
Question -- what if other users have the same program open? How do I make sure it only kills the instance that the user started? I imagine through PID but I want the process to be automatic
 
Last edited:

yinan

Golden Member
Jan 12, 2007
1,801
2
71
I do not understand the question. Is this being run on a terminal server or individual users desktops?
 

LittleNemoNES

Diamond Member
Oct 7, 2005
4,142
0
0
I do not understand the question. Is this being run on a terminal server or individual users desktops?

TS server -- that's what makes it a little touchy. Using my script would close everybody's intance of the app...

A colleague and I are going to use powershell for this because the task is a little more complicated than it initially seemed.