Auto-terminate a Windows application after a given amount of time

I might be late here but you can basically do it by using command prompt

  1. Open notepad
  2. Copy/paste this code

    cd "PATH OF THE .EXE FILE"
    start APP.exe
    timeout /t 3600
    taskkill /im APP.exe /f
    
  3. Save the file as .bat

the timeout is in seconds, to cancel it just close the command prompt


I'm answering my own question. Well, actually, the question was answered accurately and completely by user BigBadWolf_000 on Experts Exchange. I'm copying his VBScript code below:

Dim PromptTime, DelayTime, StrAppPath, AppExec, MsgTxt, intAnswer, intRet

Set objShell = CreateObject("WScript.Shell")

PromptTime = 60
DelayTime = 5
StrAppPath = "C:\windows\"
AppExec = "notepad.exe"
MsgTxt = "Do you want Notepad to close in 5 minutes?"

objShell.Run chr(34) & StrAppPath & AppExec & chr(34), 1, "False"
Do
    WScript.Sleep (1000 * 60 * PromptTime)
    intAnswer = Msgbox(MsgTxt, vbYesNo, "Please select Yes or No")
    If intAnswer = vbYes Then Exit Do
Loop

WScript.Sleep (1000 * 60 * DelayTime)
Set objWmi = GetObject("winmgmts:") 
Set objQResult = objWmi.Execquery("Select * from Win32_Process where name like '" & AppExec & "'")
For Each objProcess In objQResult 
intRet = objProcess.Terminate(1) 
Next 

Set objShell = Nothing
Set objWmi = Nothing 
Set objQResult = Nothing

Here are the explanatory comments included with BigBadWolf_000's code:

The script below will do the following...
- lauch your application (app must be launched with this script)
- Promt you for action after an hour "Do you want YourApp to close in 5 minutes?" Yes/No
- Yes: Terminates all instances of the app after 5 minutes
- No: Restarts the clock and will prompt you again in an hour

The default PromptTime is set to 60 minutes and the terminate app DelayTime is set to 5 minutes.
You can change number for PromptTime = 60 and DelayTime = 5 to any number in minutes (minimum 1). The default app is set to Notepad so you can test.

Change the path of the app executable...
StrAppPath = "your path goes here, end with  \" 

Change the name of the app executable...
AppExec = "whatever.exe"

Change the popup message txt...withing the quotes
MsgTxt = "Do you want Notepad to close in 5 minutes?"

Copy and paste script to notepad and save as yourfilename.vbs. Double-click on the file to run or create a shortcut to it. Will work with Windows 7 and Windows XP SP3.

You can use AutoIt script for this.