====== Task Scheduler ====== ------------------------------------------------------------------------------------------------------------------------------------------------\\ ====== Shortcut to run Task Scheduler "Task" ====== 2021-05-20 • Close Task Scheduler. Right-click an empty spot on your Desktop and select New > Shortcut. In the Create Shortcut window enter the following text: C:\Windows\System32\schtasks.exe /run /TN "marcus\TaskName" C:\Windows\System32 Where "TaskName" is the name of the task you chose, from step 3. Note: Include the quotation marks around the TaskName or it will fail to successfully run the task. Click Next and then enter a name for the shortcut. When done, click Finish. From ====== How to run cmd from Task Scheduler ====== Syncthing: Request revert of a receive only folder. Program/Script:\\ cmd Add Arguments Optional: \\ /c "curl -X POST -H "X-API-Key:..." http://127.0.0.1:8384/rest/db/revert?folder=default" Program/Script:\\ cmd Add Arguments Optional: \\ /c ""C:\Program Files\Python37\python.exe" "C:\Users\Public\Downloads\DropboxMaintenance\DropBoxMaintenance.py" D:\Server1\Dropbox > "C:\Users\Public\Downloads\DropboxMaintenance\Dropbox\DropboxMxLog.txt"" Note Double quotes Second example Program/Script:\\ cmd Add Arguments Optional: \\ /c ""C:\Users\Public\Downloads\rclone-v1.51.0-windows-amd64\rclone.exe" sync --create-empty-src-dirs C:\Users\rosejasmine\Desktop\stuffforClients \\ERVER1\Dropbox\VPN\stuffforClients -v --log-file="C:\Users\Public\Downloads\rclone-v1.51.0-windows-amd64\rcloneMxLog.txt"" Program/Script: \\ cmd Add Arguments Optional:\\ /c ""C:\Users\Public\Downloads\rclone\rclone.exe" sync --create-empty-src-dirs "F:\Shared" "H:\DriveF\Shared" --log-file="C:\Users\Public\Downloads\rclone\rcloneMxLog.txt"" Note Double quotes\\ if you need to monitor what happens over time, you can use --log-file=mylogfile.txt I'd recommend using it in combination with -vv to get the fullly verbose debug output for troubleshooting Depending on what user you are currently running as the default locations rclone will look for config fil… From Run from bat file\\ C:\Users\Public\Downloads\RClone\rclone.exe sync --create-empty-src-dirs "C:\Users\adept\Desktop\SoftwareW10\Size Free" \\SERVER1\WSbackup\adept-backup -vv --log-file=C:\Users\Public\Downloads\RClone\rcloneMxLog.txt Program/Script: "C:\Program Files\Beyond Compare 4\BCompare.exe" Add Arguments Optional: /silent @"C:\Users\Public\Downloads\BeyondCompareScripts\Engineeringdata\SyncTwoSpecificFolders.txt" Where SyncToSpecificFolders.txt # E N G I N E E R I N G D A T A # A sample command line, calling the a script: # "C:\Program Files\Beyond Compare 4\BCompare.exe" /silent @"C:\Users\Public\Downloads\BeyondCompareScripts\Engineeringdata\SyncTwoSpecificFolders.txt" # Turn logging on. log normal "C:\Users\Public\Downloads\BeyondCompareScripts\Engineeringdata\My Log.txt" ## Load the default session and exclude all but certain file types. #load #filter "*.html;*.htm;*.png;*.jpg" # Load the base folders. #load "C:\My Folder" ftp://user@website.com/folder load "E:\Engineering\scandata" "I:\Engineering\scandata" # Copy different files left to right. ## Copy different files left to right, delete orphans on right. ## sync mirror:left->right ## Copy different files left to right. #sync create-empty update:left->right sync create-empty mirror:left->right ====== How do I run a ps1 elevated as a scheduled job ====== powershell From: https://social.technet.microsoft.com/Forums/ie/en-US/97a24d7e-6e9e-4eb0-932e-b9d2e7ddf195/how-do-i-run-a-ps1-elevated-as-a-scheduled-job?forum=winserverpowershell VeryGood: https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler powershell.exe -executionpolicy bypass -file "Set-PowerShellScript.ps1" On the system that the task will be run from, open the Windows Task Scheduler. This can be found in the Start menu, under Start > Administrative Tools. In the Task Scheduler, select the Create Task option under the Actions heading on the right-hand side. Enter a name for the task, and give it a description (the description is optional and not required). In the General tab, go to the Security options heading and specify the user account that the task should be run under. Change the settings so the task will run if the user is logged in or not. Next, select the Triggers tab, and click New to add a new trigger for the scheduled task. This new task should use the On a schedule option. The start date can be set to a desired time, and the frequency and duration of the task can be set based on your specific needs. Click OK when your desired settings are entered. Next, go to the Actions tab and click New to set the action for this task to run. Set the Action to Start a program. In the Program/script box enter "PowerShell."In the Add arguments (optional) box enter the value ". Then, in the Start in (optional) box, add the location of the folder that contains your PowerShell script. In this example, the script is in a folder called "Script" that is off the root C: drive. Note: The location used in the Start in box will also be used for storing the scheduled task run times, the job history for the copies, and any additional logging that may occur. Click OK when all the desired settings are made. Next, set any other desired settings in the Conditions and Settings tabs. You can also set up additional actions, such as emailing an Administrator each time the script is run. Once all the desired actions have been made (or added), click OK. The task will be immediately set, and is ready to run.