SHARE
TWEET

Create_Scheduled_Task.bat

hackoo Jan 17th, 2020 338 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. color 0A & Mode 80,5
  3. Title Create a scheduled vbscript file to be executed every hour by Hackoo
  4. :::::::::::::::::::::::::::::::::::::::::
  5. :: Automatically check & get admin rights
  6. :::::::::::::::::::::::::::::::::::::::::
  7. REM  --> Check for permissions
  8. Reg query "HKU\S-1-5-19\Environment" >nul 2>&1
  9. REM --> If error flag set, we do not have admin.
  10. if '%errorlevel%' NEQ '0' (
  11. Echo.
  12. ECHO                      **************************************
  13. ECHO                       Running Admin shell... Please wait...
  14. ECHO                      **************************************
  15.  
  16.     goto UACPrompt
  17. ) else ( goto gotAdmin )
  18.  
  19. :UACPrompt
  20.     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  21.     set params = %*:"=""
  22.   echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
  23.  
  24.   "%temp%\getadmin.vbs"
  25.   del "%temp%\getadmin.vbs"
  26.   exit /B
  27.  
  28. :gotAdmin
  29. ::::::::::::::::::::::::::::
  30. ::START
  31. ::::::::::::::::::::::::::::
  32. set "VBSFilePath=%~dp0NASA_Wallpaper.vbs"
  33. set "TaskName=NASA"
  34. set "Repeat_Task=60"
  35. Call :Create_Schedule_Task "%TaskName%" "%VBSFilePath%"
  36. Rem 60 minutes = 1Hour
  37. rem Call :Create_Schedule_Task %Repeat_Task% "%TaskName%" "%VBSFilePath%"
  38. Rem Just to query the TaskName
  39. Schtasks /Query /TN "%TaskName%" | find /i "%TaskName%"
  40. pause & exit
  41. ::***********************************************************************
  42. :Create_Schedule_Task <Repeat_Task_Every(N)Minute> <TaskName> <FilePath>
  43. REM Schtasks /create /SC minute /MO %1 /TN "%~2" /TR "%~3"
  44. Schtasks /Create /SC DAILY /ST 08:00 /F /RI 60 /ET 17:00 /TN "%~1" /TR "%~2"
  45. exit /b
  46. ::**********************************************************************
  47. REM schedule something to run at 7:00 every day every 1 hour for a duration of 1 day.
  48. Rem schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00
  49. rem rem https://stackoverflow.com/questions/21437787/schtasks-create-have-a-task-that-runs-every-day-and-repeats-every-hour
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top