Hi I'm attempting to create a Message box with a "DELAY" button If the user does not press the Delay button the script will launch a batch file (or command)
So it should go like this:
Hello User Your Administrator has requested you to log out of this application after work, we have detected you are still using the program, please press Delay if you are still at your machine.
Ideally, I would like it to detect when a certain program is active, and only activate if it is
Thanks
Here is the final version
@if (@CodeSection == @Batch) @then
@echo off
setlocal
for /f %%I in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"') do set "beep=%%I"
set /P "=%beep%"<NUL
set /P "=%beep%"<NUL
set /P "=%beep%"<NUL
setlocal
set "task=agent.exe"
set "timeout=120"
rem // Is %task% running?
tasklist /fi "imagename eq %task%" | find /i "%task%" >NUL && (
rem // Re-launch script with JScript interpreter
wscript /e:JScript /nologo "%~f0" %timeout% || (
rem // If timeout or user hits No, kill %task%
taskkill /im "%task%" /f
)
)
rem // End main runtime
goto :EOF
rem // Begin JScript portion
@end
var osh = WSH.CreateObject('WScript.Shell'),
nag = 'Greetings! Your administrator has requested you to log out of Touchstar '
+ 'after work. It appears you are still using it.'
+ ' If you are still here, Press Yes to continue working.\n\n'
+ 'Otherwise, press no to close touchstar.'
+ 'Touchstar will close automatically in less than ' + WSH.Arguments(0) + ' seconds.';
popup = osh.Popup(nag, WSH.Arguments(0), 'Are you still here?', 0x4 + 0x20 + 0x1000);
WSH.Quit(popup - 6);
Thank you to all who helped create this (big shoutout to Rojo), and all who answered.
- Denslat