Home / How to / Tips and Tools – Automate Repetitive Tasks on Windows 10

Tips and Tools – Automate Repetitive Tasks on Windows 10

Tips and Tools to Automate Repetitive Tasks on Windows 10

Do you regularly wind up erasing old files, cleaning the unrequired information, beginning a few projects, and so forth physically? On the off chance that it’s yes, at that point let me help you automate and do more in less time. In spite of the fact that these computerizations don’t spare much time, yet measuring the need of the time, any measure of time spared merits attempting.

I’ll begin by acquainting you with few Windows apparatuses that assistance us in robotizing certain undertakings, and afterward I’ll demonstrate to you a few cases of me computerizing errands on my Windows 10 PC.

Apparatuses you should know

Possibly you’ve effectively known about these apparatuses — Command Prompt, PowerShell, and Task Scheduler. If not, not to stress; let me acquaint you with these devices in this area.

Summon Prompt and bunch documents

Summon Prompt, a successor to MS-DOS Prompt, is an order line translator program. What’s more, a record having different of its orders is known as a “group document”, which you can use to robotize assignments, e.g., to reinforcement a record or envelope to a convenient drive. In the event that you wish to give it a shot, type “cmd” or “Summon Prompt” in Start menu’s inquiry bar, and you’ll see it.

 

You just need to compile the required commands in a text file having “.bat” or “.cmd” extension. And you can simply open the file to run it; in this case, Windows 10 executes all the file’s commands sequentially or as programmed in the batch file.

List of commands | How to use

PowerShell and its script files

PowerShell is an automation and management framework built for power users aka system admins. If you’re looking for true automation potential, then you need to learn and use PowerShell.

I must tell you that Command Prompt is much easier to learn and use than PowerShell because the latter offers lot more power and features than the former.

You can access Windows PowerShell by typing its name in the Start menu’s search box. Do note that you’ll see two programs — “PowerShell” and “PowerShell ISE”. PowerShell is the command-line interpreter program like Command Prompt whereas the other is used to write scripts (having “.ps1” extension), which contain a group of commands like batch files.

List of commands | How to use | More info

Task Scheduler and its tasks

Another Windows tool that helps in automation is Task Scheduler — a program to schedule programs and tasks. The scheduled tasks run at specific time intervals, can display messages or notifications to show when the tasks are complete, and a lot more. Moreover, you can customize the tasks to suit your requirements.

If you wish to access Task Scheduler in Windows 10, just type “scheduler” or “Task Scheduler” in Cortana’s search box, and you’ll find the scheduler program. Do note that even Windows and various installed programs (like Google Chrome) create scheduled tasks to do their own maintenance activities, so please don’t edit or disable other tasks.

How to use | More info

Let’s automate tasks

Now that you know about the required tools, let’s create some magical scripts and tasks. These scripts cum tasks, if configured properly, can automate various maintenance tasks on your computer without the need of you checking or intervening in these activities.

Start multiple apps

If you find it slow to open multiple required files on every startup, then you can automate it like I did. Just identify some folders, files, and programs you want to start simultaneously and create a batch file. You can also create a shortcut to this file and add a key combination to this shortcut to launch it quickly using the shortcut keys.

For instance, you can create a batch file to open few specific folders, Google Chrome browser, a Word file, and an Excel file using code below. Do note that “%USERPROFILE%” in the below refers to your user profile’s directory in Windows.

1
2
3
4
5
6
7
8
9
@echo off
:: Open folders
start %USERPROFILE%\Documents\
start %USERPROFILE%\Desktop\MusicFolder\
:: Open files
start chrome.exe
start "" "%USERPROFILE%\Documents\My Blogs\Article1.docx"
start "" "%USERPROFILE%\Documents\Content Ideas.xlsx"
exit

Start apps as admin

You must have got success in starting apps using the previous script, but to run a program as an administrator doesn’t work the same way. It’s because the elevated program starts but asks for the admin access by showing a UAC prompt. But if you’re not there to give your approval to the prompt, the program simply exits, i.e., doesn’t starts at all.

The same doesn’t work using a shortcut placed in the Windows Startup folder too. So, how to do it? Task Scheduler program comes to our rescue for this problem. It only features an option to run a program with elevated privileges, so you can start an app or a group of apps (using a batch script) using Task Scheduler. Here’s how to do it:

    1. Open the Task Scheduler > click “Create Task” under Actions in the right panel.
    2. Under the General tab, add a task name like “NoUAC1”, then check “Run with highest privileges” box.
    1. Click the Trigger tab, under “Begin the task“, choose “At startup“.
    2. Now switch to the Actions tab, click New.
    3. In the New Action window, for Action select “Start a program“, and under Program/script, click Browse button, choose the executable file you wish to schedule and click OK.
  1. Now head over to the Settings tab > ensure “Allow task to be run on demand” is checked and then click OK to save.
  2. That’s all. Now the set program (Adobe Reader per this tutorial) will start automatically with administrative privileges whenever you start the system.

Delete all old files

Being a tech enthusiast and developer, I usually download and test various things, and then after a month or two, I see a host of unneeded files on my system. Thankfully, a batch script helps me to delete old downloaded files.

Similarly, you can use a batch file to delete all old files of specific extensions or files in a given folder or a subfolder, which are older than the set date and time. Using the code below, one can delete .docx files (change “docx” to match your files) in any specific folder older than twenty days (change the value of “/d” option to set any number of days).

1
2
3
4
5
@echo off
forfiles /p "%USERPROFILE%\Documents\My Blogs" /s /m *.docx /d -20 /c "cmd /c del @path"
echo Document files older than 20 days deleted
pause
exit

And you can change the path (by changing the value of “/p” option) to the folder containing the files to be deleted. Below, “%USERPROFILE%” means your user’s directory.

Empty recycle bin

It’s recommended to clear the recycle bin regularly, and though it’s an easy task yet we may often forget it. Thankfully, this can be handled automatically using the Task Scheduler. Here are the steps to auto-optimize the hard drive’s free space:

    1. Open the Task Scheduler.
    2. Open up “Task Scheduler Library“, then under Action menu click “New Folder” and name it “My Tasks”.
    3. Click on “My Tasks” folder, and select “Create Task” from Action menu.
    4. In the Create Task window under the General tab type the task name as “Empty Windows Recycle Bin”.
    5. Click Triggers tab, here click New and under “Begin the task” choose “On a schedule“.
    6. Choose the Weekly or Monthly option per your preference as this will give you enough time to recover/undelete files that you may need, and click OK.
    1. Click Actions tab, go to New, and in New Action window, under Settings >for Program/script, type in “PowerShell.exe”.
    2. In the same window, for “Add arguments (optional)” type -NoProfile -Command "Clear-RecycleBin -Force" and click OK button.
  1. That’s all — just save the task, and now the bin will be cleaned on scheduled basis.

Turn off the system

As I couldn’t stop myself from working late at night, I decided to force myself to abandon the work and go to sleep. And that’s where the below script helped me out.

The below-mentioned code will show the message (you can edit it in the script) at 11PM, and turn off the system after 120 seconds (or 2 minutes). Do note that you can even change the auto shutdown time in the code below by changing the corresponding value of “%time%”.

1
2
3
4
5
6
7
@echo off
:a
If %time%==23:00:00.00 goto :b
goto a:
:b
shutdown.exe /s /f /t 120 /c "Time To Say Good Night!"
exit

Note: You get 120 seconds (edit “120” in above script to change this duration) to save your work instead of the default 30 seconds. Also, you can stop the shutdown by pressing Win+R type shutdown -a press Enter. It’s pretty easy, right?

Backup files/folders

Well, I know we have pretty good programs for backing up our files including cloud solutions such as Dropbox and Google’s Backup and Sync. However, if you want extreme control and wish to backup extremely sensitive files to your portable hard drive, then a batch script is a nice, automated solution. And it’s pretty easy and need no download.

Do note that this method just backs up specific files and folders and doesn’t create a standard system restore point or a system backup. I make use of the “robocopy” command to backup files in this script. Here’s the batch file’s code to backup the complete data inside your user directory and also backup the system registry:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off
:: Set the folder to backup below
set sourcedir=C:\Users\USER
:: Set your portable drive's folder below
set targetdir=D:\Backup
if not exist "%targetdir%" mkdir "%targetdir%"
echo ### Backing up your profile…
robocopy %sourcedir% %targetdir% * /e /j /r:10 /v
echo ### Backing up the registry…
if exist "%targetdir%\regbackup.reg" del "%targetdir%\regbackup.reg"
regedit.exe /e "%targetdir%\regbackup.reg"
echo ### Backup is all complete…
pause
exit

About Syed Sarim

Check Also

The New Gmail – Material Design and 8 New Features

The New Gmail – Material Design and 8 New Features Gmail has received a major …

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: