Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem -- v.02 --
- setlocal
- if "%1" EQU "" (
- echo starts a hidden process
- echo by Vasil "npocmaka" Arnaudov
- echo %~n0 path_to_executable
- goto :eof
- )
- if "%1" EQU "-help" (
- echo starts a hidden process
- echo by Vasil "npocmaka" Arnaudov
- echo %~n0 path_to_executable
- goto :eof
- )
- set executable=%~s1
- set inpath=%~dp$PATH:1
- ::the idea behind this ugly if is
- :: to get the path in 8.3 format because there are problems between
- :: SCHTASKS and spaces
- if not exist %executable% (
- if "%inpath%" equ "" (
- echo path to executable item does not exist
- exit /B 1
- ) else (
- for %%f in ("%~dp$PATH:1%~1") do set executable=%%f
- )
- )
- ::getting the current time
- FOR /F "skip=1 tokens=1-3" %%A IN ('WMIC Path Win32_LocalTime Get Hour^,Minute^,Second /Format:table') DO (
- SET /A hours=%%A > nul 2>&1
- SET /A minutes=%%B > nul 2>&1
- SET /A seconds=%%C > nul 2>&1
- )
- set /a time_stamp=%hours%%minutes%%seconds%
- if "%time_stamp%" equ "" (
- echo "some kind of error"
- exit /B 2
- )
- SCHTASKS /Create /SC ONEVENT /EC Application /MO *[System/EventID=101] /TN start_at_%time_stamp% /TR %executable% /RU SYSTEM /F /RL HIGHEST
- eventcreate /ID 101 /T INFORMATION /D start_task
- SCHTASKS /Delete /TN start_at_%time_stamp% /f
- endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement