5 Simple Windows Scripts to Save Time

5 Simple Windows Scripts to Save You Time and Effort

5 simple scripts to save time

For a beginner, getting into scripting can be very intimidating. However, there are some major benefits to using scripts on your Windows 10 PC. If you’re just getting started, using Windows scripts written by others can often give you a good idea of how things work.

To learn scripting step-by-step, take a look at the simple Windows scripts featured in this article, and go from there. Figure out how they work. Think about how you might tweak them for yourself. Once you’re comfortable with what a script is, you can think about diving into the nitty-gritty of coding.

Scripting With PowerShell

Many Windows users know PowerShell as a command line interface. However, we can also use PowerShell commands to create a script that we can call upon at a later date.

1. Shut Down Your Computer

You can shut down a Windows 10 PC with just a couple of clicks, but is that fast enough? By implementing a PowerShell script, we can place a shut down button anywhere on our desktop. Furthermore, we can learn how to make a script shortcut at the same time.

Open up Notepad and type out the following:

shutdown -s -t 0

Next, click File > Save As.

5 Simple Windows Script

Name the file shutdown.cmd and use the Save as type dropdown to select All Files. Run this file with administrator privileges, and your PC will shut down instantly.

By tweaking this script slightly, we can schedule a restart on a timer. To do so, make the following edit to your .cmd file:

shutdown -r -t 60

The above will make your PC restart after a period of 60 seconds has elapsed. The -r in place of the -s we used above prompts the restart, while the -t tag stipulates the time. Feel free to tweak the integer to set a different span of time.

2. Remove Pre-Installed Windows 10 Apps

There are many benefits to installing Windows 10, but it’s fair to say that the operating system (OS) comes packaged with several apps that qualify as bloatware. Rather than removing each of these pieces of software manually, we can set up a script that does the job for us.

Before you use this technique to get rid of any apps from your user account, consider the consequences. Many programs and services do important work behind the scenes, so don’t be flippant about what you remove.Open up a PowerShell window as an administrator and use this command to remove a particular app:

get-appxpackage -name *APPNAME* | remove-appxpackage

You’ll need to find the name that Windows uses to refer to each individual app and insert it in place of APPNAME. For instance, this command would remove three commonly unwanted programs:

get-appxpackage -name *BingFinance* | remove-appxpackage
get-appxpackage -name *BingNews* | remove-appxpackage
get-appxpackage -name *BingSports* | remove-appxpackage

If you’re in charge of setting up an entire fleet of computers, this can really speed up the process. Simply figure out which apps you want to remove, write up a script that gets rid of the lot, and run it on each PC.

3. Rename a Batch of Files

So you’ve just uploaded an album of photographs to your computer? And they’re all labelled with whatever naming convention your camera uses by default? Wouldn’t it be handy if you could attach a keyword that you can search for at a later date?

A simple PowerShell script can do just that. Enter the following to rename files en masse:

$path = "$home\desktop\make use of\holidaysnaps"
$filter = '*.jpg'

get-childitem -path $path -filter $filter |
rename-item -newname {$_.name -replace ‘IMG’,‘HOLIDAY2016’}

There are a few things to tweak before you run this script. First, adjust the path so it points toward the desired folder. Check which format your images are in, and change the file type in the second line if necessary. Finally, replace “IMG” in the last line with the text you want to replace, and “HOLIDAY2016” with the text you want to sub in.

However, use caution when you’re working with a script like this one. It doesn’t take long for the command to rename every single file in a folder — and that can cause big problems if it’s pointed toward the wrong directory.

4. Open a Folder in an Instant

We all have folders that we return to on a regular basis. Sometimes it’s convenient enough to place them on our desktop, but sometimes it would be even better if we could enter a keyboard shortcut to open it up while we’re working on a separate task.

AutoHotKey allows you to set up a custom shortcut for any location on your computer. To do so, create a script that contains the following code:

#^d::Run "C://Users/Brad/Downloads"

To get this code to work, you’ll need to replace “Brad” with your own Windows username. If you’re new to AutoHotKey and that script looks like gibberish, don’t fret — it’s more straightforward than you might think.

The first part of the text stipulates the button combination that the user will need to use to execute the script, in our case the Windows key (#), the Shift key (^), and the D key. This shortcut is linked to the Run command we’re trying to execute by a pair of colons.

5. Take Control of Your Virtual Desktops

Windows 10 introduced virtual desktops, a useful way of setting up distinct environments for different tasks. This functionality makes it easy to organize your workspace. However, switching between different desktops can be a little more unwieldy than a simple Alt-Tab.

Fortunately, there’s an AutoHotKey script that allows you to immediately transfer to a different desktop using a simple keyboard shortcut. It also makes it easy to create and delete desktops as required. The code and an explanation of how the script works is available via GitHub.

6. Get System-Wide Autocorrect Functionality

Autocorrect isn’t perfect, but it can be very handy if you’re prone to the occasional spelling mistake. Some mobile operating systems like iOS deliver autocorrect functionality no matter what app you’re using. You can get the same assistance on PC by implementing an AutoHotKey script.

You can grab a pre-built version of the script over at HowToGeek. However, it’s well worth customizing the code to calibrate it for your usage. For instance, if you regularly use slang words, you’ll want to make sure they don’t get corrected erroneously.

7. Make Sure Sentences Start With a Capital Letter

If system-wide auto-correct seems too drastic, you might be better off with this tweak that counteracts a common typing error. Proper capitalization is a must if you want your writing to look professional, and you can use Auto-HotKey to double-check your work for mistakes.

You can find the necessary code on the AutoHotKey forum. The script makes sure that any period, question mark, or explanation mark will be followed by a capital letter.

Next Steps in Scripting

The internet gives us access to a whole host of scripts developed by others that we can pick and choose from. That’s great, but the most useful scripts are often the ones you create for yourself.

The scripts in this article perform tasks that don’t require your oversight. These tasks will vary from user to user. A working knowledge of how scripts work is the first step towards making scripts that are tailored to your own usage.

Scripts you find online can certainly save you time and effort. However, if you take the time to really get to grips with tools like PowerShell and AutoHotKey, you might be surprised by what you can come up with.

Comment here