How to get Cortana to perform custom tasks on Windows 10
You can execute virtually any command using Cortana on Windows 10, and in this guide, we'll show you how.
Cortana on Windows 10 is your personal assistant that can help you to keep up with your daily tasks, answer questions, and allows you to use voice commands to get things done hands-free.
Although the assistant can be handy, it's still limited to the tasks it can perform. For example, you can use voice commands to execute various power options, but there isn't a command to put your PC into hibernation or sleep mode. Further, while you can use commands to open a specific section in the Settings app, Cortana can't change a particular setting on its own.
However, it's possible to use Cortana's "Open" command to run a shortcut linked to a particular command or script that allows you to perform virtually any task using only your voice.
In this Windows 10 guide, we'll walk you through the steps to create custom commands that Cortana can execute on your behalf.
How to execute custom commands using Cortana
In the instructions below we'll go through the steps to create a shortcut that executes a particular command, and you'll also learn the steps to perform a more complex task running a script.
Executing a command
In the following example, you'll be creating a command to put your computer into hibernation mode using voice command.
- Use the Windows key + R keyboard shortcut to open the Run command.
- Type the following path and click OK:
C:\Users\YOUR-USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
- Right-click on an empty area, select New, and click on Shortcut.
- In the "Type the location of the item" field, enter the command you want to execute. For example, if you want to hibernate your computer, use this command:
shutdown.exe -h
- Click Next.
- Type a descriptive name for the shortcut, which will also be the voice command that will allow Cortana to run the task. For example, Hibernate Device.
- Click Finish.
Once you've completed the steps, you can use the "Hey Cortana, Open Hibernate Device" voice command to hibernate your computer.
Get the Windows Central Newsletter
All the latest news, reviews, and guides for Windows and Xbox diehards.
If you want to put your device into a sleep mode, on step No. 4, make sure to use this command instead:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Running a script
In the following example, you'll be creating a command to execute a script using Cortana to switch from the light to the dark theme using a voice command.
Warning: This is a friendly reminder that editing the Registry is risky, and it can cause irreversible damage to your installation if you don't do it correctly. It's recommended to make a full backup of your PC before proceeding.
- Open File Explorer (Windows key + E).
- Browse into a folder you want to store the script.
- Right-click on an empty area, select New, and click on New Text Document.
- Type a name for the file, make sure to change its file extension from .txt to .bat, and press Enter.Quick Tip: If you don't see the file extension, click the View tab in File Explorer, and check the File name extensions option.
- Right-click the .bat file and select Edit.
- Copy and paste the following command into the batch file:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force
- Save the file as you would normally do with any text file (Ctrl + S).
- Right-click the file and select Create shortcut.
- Select the shortcut, press F2, remove the ".bat - Shortcut" as part of the name, and press Enter.
- Right-click the shortcut, and select Cut.
- Use the Windows key + R keyboard shortcut to open the Run command.
- Type the following path and click OK:
C:\Users\YOUR-USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
- Right-click on an empty space and select Paste.
After completing the steps, you can run the "Hey Cortana, Open Enable Dark Theme" voice command to switch from the light to the dark theme on Windows 10.
If you want to switch back to the light theme, you can do this on Settings > Personalization > Colors, and selecting the Light option. Or you can create a second script and shortcut in the Programs folder using the same instructions mentioned above, but on step No. 6, make sure to use this command:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1
It's worth noting we're just showing you a few examples to get started, you can always create your custom commands.
In order to prevent conflicts with Cortana's built-in commands try to avoid well-known words, such as PC, computer, switch, etc., when naming your shortcut. If you're not sure, just create your custom command, and try to ask Cortana to run it using the "Hey Cortana, Open SHORTCUT-NAME" command. If the assistant is having trouble, simply change the name of the shortcut to something else, and try again.
Also, it might take a few moments until Cortana can detect the new shortcuts in the Programs folder. The easiest way to find out is to open the Start menu, and check if your shortcuts appear in the "Recently added" list.
More Windows 10 resources
For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:
- Windows 10 on Windows Central – All you need to know
- Windows 10 help, tips, and tricks
- Windows 10 forums on Windows Central
Mauro Huculak has been a Windows How-To Expert contributor for WindowsCentral.com for nearly a decade and has over 15 years of experience writing comprehensive guides. He also has an IT background and has achieved different professional certifications from Microsoft, Cisco, VMware, and CompTIA. He has been recognized as a Microsoft MVP for many years.