How to get Cortana to perform custom tasks on Windows 10

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.

  1. Use the Windows key + R keyboard shortcut to open the Run command.
  2. Type the following path and click OK:C:\Users\YOUR-USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
  3. Right-click on an empty area, select New, and click on Shortcut.

  1. 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
  2. Click Next.

  1. 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.
  2. Click Finish.

Once you've completed the steps, you can use the "Hey Cortana, Open Hibernate Device" voice command to hibernate your computer.

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.

  1. Open File Explorer (Windows key + E).
  2. Browse into a folder you want to store the script.
  3. Right-click on an empty area, select New, and click on New Text Document.

  1. 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.

  1. Right-click the .bat file and select Edit.
  2. 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
  3. Save the file as you would normally do with any text file (Ctrl + S).

  1. Right-click the file and select Create shortcut.

  1. Select the shortcut, press F2, remove the ".bat - Shortcut" as part of the name, and press Enter.
  2. Right-click the shortcut, and select Cut.
  3. Use the Windows key + R keyboard shortcut to open the Run command.
  4. Type the following path and click OK:C:\Users\YOUR-USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
  5. 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:

Mauro Huculak is technical writer for His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he's a recognized member of the Microsoft MVP community.

  • Awesome article!  One of the biggest problems I have with digital assistants is that I have no idea what commands they understand.  If you know how to script, then you can make your own like you have shown. Microsoft used to be then leader making computers assessable to the common user.  Why don't they have a create macro feature under Cortana and a low users to create their own macros like in Office.
  • Cortana should be able to do stuff without adding shortcuts
  • ?   Cortana has a lot of 'stuff' she can do.. In fact a lot of settings/toggles are already built in.... Like " Hey Cortana, Turn off Bluetooth" or "Turn on Quiet Hours"
  • ...the only thing more language support.