Task Scheduler in Windows or Cron in Linux is a life saver on the Sys Admin world.
Why it is a life saver? You can set a scheduled task and forget
about it. Of course, provided you have already carefully examined and test
multiple times what will be the output when the Task is triggered.
Yes, set and forget; once you are confident enough that everything
will go smoothly.
If there are task that needs to be run at midnight or early
hours in the morning, Task Scheduler will come in handy.
So, how do we set a Task Scheduler using PowerShell or
Command Prompt?
Why need to learn both? And not just PowerShell?
Well, command prompt is always available on all Windows
distribution. While PowerShell might be available on newer Windows system but
then some restriction might be in place for security reasons.
Therefore, it is good to be familiar with both PowerShell
and Command Prompt executable files.
PowerShell code snippet below shows how to set or create a
Task Scheduler. PowerShell must be run in an elevated mode or with admin rights.
$action = New-ScheduledTaskAction -Execute "c:\windows\notepad.exe
" `
-Argument 'C:\Users\JohnD\Desktop\reminder.txt'
$trigger = New-ScheduledTaskTrigger -Daily -At 9:05am
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "ReminderApp" -Description "Notepad
Reminder - every 9:05AM"
# C:\Users\JohnD\Desktop\reminder.
This path can be pointing to any location
Above command will create a task that will open Notepad every
9:05am.
To verify, open Task Scheduler from Control Panel or just
search for it and check. There will be a task called “ReminderApp”.
To delete or unregister
a scheduled task using PowerShell use this command:
Unregister-ScheduledTask -TaskName ReminderApp -Confirm:$false
To set or created a scheduled task using command prompt use this command below using schtasks.exe.
Running schtasks command doesn't need to use an elevated command prompt but this will only run on the user context running the command.
SCHTASKS /CREATE /SC DAILY /TN "Notepad Reminder App"
/TR "C:\Windows\System32\notepad.exe 'C:\Users\JohnD\Desktop\reminder.txt'"
/ST 09:00
Above command will create a task called “Notepad Reminder
App” and it will run every 9:00am daily.
Above examples will open notepad, but it can be changed
with any command as desired.
Notepad reminder though is quite simple, and its easy to add
or fill in any notes that you want. Of course, this will depend on your taste and how you organize
your daily task.
Cheers! Take care. Till next Time.
Stay safe! and Keep things up!
Do ASAP, Always Say A Prayer...
Practice O.T.G. = Obedience To God
================================
Free Android Apps:
Click links below to find out more:
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
Divine Mercy Chaplet Guide (A Powerful prayer) BFF = Be Filled Faith:
Comments
Post a Comment