-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelay-launch.bat
45 lines (37 loc) · 1.02 KB
/
delay-launch.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@echo off
setlocal EnableDelayedExpansion
:: Check if argument is provided
if "%~1"=="" (
echo Error: Please provide a program to run
echo Usage: %~nx0 program.exe
echo or: %~nx0 program.bat
exit /b 1
)
:: Verify file exists
if not exist "%~1" (
echo Error: File "%~1" not found
exit /b 1
)
:: Store the full path of the target program
set "PROGRAM=%~f1"
:input_minutes
set /p "MINUTES=Enter the number of minutes to wait (1-1440): "
:: Convert minutes to seconds for timeout
set /a SECONDS=MINUTES*60
:: echo Seconds: %SECONDS%
:: echo.
:: echo Will launch "%~nx1" in %MINUTES% minutes...
:: echo Press Ctrl+C to cancel
:: Show countdown and then launch
:countdown
set /a "mins_left=%SECONDS%/60"
set /a "secs_left=%SECONDS%%%60"
cls
echo Launching "%~nx1" in %mins_left% minutes and %secs_left% seconds...
:: echo Press Ctrl+C to cancel
timeout /t 1 /nobreak >nul
set /a SECONDS-=1
if %SECONDS% GTR 0 goto countdown
:: Launch the program
start "" "%PROGRAM%"
exit /b 0