Estou respondendo a minha própria pergunta. Bem, na verdade, a pergunta foi respondida com precisão e completamente pelo usuário BigBadWolf_000 em Especialistas em troca . Estou copiando o código do VBScript abaixo:
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
Aqui estão os comentários explicativos incluídos no código do BigBadWolf_000:
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.