How to run a custom task in Windows 10 with Cortana

That means users can create batch scripts or shells or create their own program to do almost anything.

Many people prefer to use voice commands with Cortana on Windows computers. However, there are certain tasks that Cortana cannot do. And so, users must continue to find ways to work more with Cortana without waiting for Microsoft to add more commands.

The main goal now is to expand the functionality of Cortana and, fortunately, allow calling or running any script or program installed on the computer. That means users can create batch scripts or shells or create their own programs to do almost anything. Now let's see the specific instructions through the following article!

'Hey Cortana, open .'

For example, we often say 'Hey Cortana, open Chrome' to open Google Chrome. It not only can open system tools (such as Task Scheduler ) or installed programs (like Google Chrome), but also can run any shortcut in the Start menu. That means that such a shortcut can point to any program or script - even custom programs.

Create a shortcut in the Start menu

Since any shortcut in the Start menu can be executed by Cortana, so this is how you can create a shortcut:

1. Press Win + R key to open the Run window.

2. Type shell: programs in the window, then click OK .

How to run a custom task in Windows 10 with Cortana Picture 1How to run a custom task in Windows 10 with Cortana Picture 1

3. Open the Run window .

4. File Explorer will open, displaying the folder ' Start Menu> Programs '.

How to run a custom task in Windows 10 with Cortana Picture 2How to run a custom task in Windows 10 with Cortana Picture 2

5. Right-click an empty area, select New and select Shortcut .

6. When you have finished entering the path, just click the Next button.

How to run a custom task in Windows 10 with Cortana Picture 3How to run a custom task in Windows 10 with Cortana Picture 3

Now you need to name your shortcut. Choose a meaningful and easy-to-read name because this will be the command you have to tell Cortana to run your custom task. For example, if you set ' Sesame ' as the name for the shortcut, just say 'Hey Cortana, open Sesame'.

Set the location for the shortcut in the Start menu

We can also place a shortcut in the Start menu. Although this method does not work for individual commands, we can create shortcuts for programs or scripts easily, and then set that shortcut in the Start menu.

Follow the steps below to quickly create and position the shortcut:

  1. Right-click any program or script you want to create a shortcut.
  2. You will see the context menu appear. Please select the option ' Create shortcut '. How to run a custom task in Windows 10 with Cortana Picture 4How to run a custom task in Windows 10 with Cortana Picture 4
  3. You should now see a new shortcut with the program or script.
  4. Right click on that shortcut, select ' Rename ' from the options list. How to run a custom task in Windows 10 with Cortana Picture 5How to run a custom task in Windows 10 with Cortana Picture 5
  5. Enter a meaningful and easy-to-read name for the shortcut. This is the name you will use to inform Cortana, when you want to execute it. For example, if you name it ' Secret ', then you must say 'Hey Cortana, open Secret' to run it.
  6. Now press Win + R key and you will see the Run window appear.
  7. Enter shell: programs in the window and click the OK button. How to run a custom task in Windows 10 with Cortana Picture 6How to run a custom task in Windows 10 with Cortana Picture 6
  8. You will see File Explorer with the folder ' Start Menu> Programs '.
  9. Now cut the shortcut created in step 2 and paste it into this folder. How to run a custom task in Windows 10 with Cortana Picture 7How to run a custom task in Windows 10 with Cortana Picture 7

Run custom tasks

Run a command or a program

If you want to run a command or a command line program (such as CCleaner) via voice commands with Cortana, you can use this method. Follow the steps above as in ' Creating a shortcut in the Start menu ' and while performing step 6, enter the full command in the ' Type the location of the item ' field.

For example, if you need to create a shortcut to put your computer into hibernation, then you need to issue a shortcut / h command in step 6. Also, if you name the shortcut as ' hibernate me ', then whenever you need to put your computer into hibernation, just say 'Hey Cortana, open hibernate me' to Cortana.

How to run a custom task in Windows 10 with Cortana Picture 8How to run a custom task in Windows 10 with Cortana Picture 8

Furthermore, suppose you need to clean up your computer with CCleaner, then you can use command line options to reduce the cleanup process. You only need to replace the command in the example above to " C: Program FilesCCleanerCCleaner.exe" / AUTO (it only works if CCleaner is installed there) and name it " autoclean me ", then just say "Hey Cortana, open autoclean me" to clean your system using this maintenance tool.

Run batch script

The batch script is a file with many commands executed by the Windows Command Prompt. If you want to run multiple commands, you must create a batch script file (with the .bat extension). To do so, follow the steps in the ' Set the location for shortcut in the Start menu' guide above to place the shortcut of the file in the Start menu.

Run the Bash shell script

The shell script is a file that has many commands, like a batch script. Although a shell script (with an .sh extension) is known to run only on Linux / Unix distributions but with the appearance of Bash on Ubuntu in Windows 10, fortunately, we can now run shell commands or scripts directly on Windows. In fact, it is one of the features that users love on Windows 10.

Unlike batch scripts, shell scripts do not execute directly just by opening them, so we cannot use the same method as with batch scripts. After you create the shell script, follow the steps in ' Create a shortcut in the Start menu ' and in step 6, enter the bash command:

 / mnt / SCRIPT-PATH 

How to run a custom task in Windows 10 with Cortana Picture 9How to run a custom task in Windows 10 with Cortana Picture 9

At the SCRIPT-PATH location, you must enter the path of the Linux / Unix-style script. For example, the file named 'my_script.sh' on the desktop has the following path:

 /mnt/c/Users/aksinghnet/Desktop/my_script.sh. 

Run the PowerShell command

PowerShell is a new, more powerful Command Prompt in Windows. It offers more commands and functions than the Command Prompt, and so it can help you do more in your system.

To create a shortcut for the PowerShell command, you must use the steps outlined above in the 'Run a command or a program' section. Again, in step 6, you must enter the PowerShell command that you want to execute.

How to run a custom task in Windows 10 with Cortana Picture 10How to run a custom task in Windows 10 with Cortana Picture 10

Moreover, you must write your commands in the following format:

 PowerShell -Command "& {COMMAND-HERE}" 

For example, if you want to disconnect and then reconnect Wi-Fi to a network called ' FastWifi ', you must use the following PowerShell command while creating a shortcut:

 PowerShell -Command "& {netsh wlan disconnect; netsh wlan connect name = FastWifi} 

Run the PowerShell script

PowerShell can also run scripts (with the .ps1 extension). It will be more useful for automating some tasks (even complex tasks) and it seems to be more powerful than batch scripts.

If you need a shortcut to run the PowerShell script, you must follow the same procedure as described above in ' Run PowerShell command ' but you must keep the command in format:

 PowerShell -File FILE-PATH 

For example, if the file is ' C: pscript.ps1 ', use PowerShell -File C: pscript.ps1 .

How to run a custom task in Windows 10 with Cortana Picture 11How to run a custom task in Windows 10 with Cortana Picture 11

Troubleshoot

Cortana cannot find or open a shortcut

How to run a custom task in Windows 10 with Cortana Picture 12How to run a custom task in Windows 10 with Cortana Picture 12

First, check if your shortcut is available in the Start menu. You can search for it in the list of ' Recently added ' in the Start menu.

Second, make sure you don't name the shortcut by command or standard name like computer, sleep, shutdown, etc. If you are using the above names, just press Win + R key, enter shell: programs and press Enter , then find your shortcut in File Explorer and give it a different name, meaningful and non-identical. with the above names.

See more:

  1. Completely disabling virtual assistant Cortana on Windows 10
  2. 18 useful commands you should try with Cortana
  3. Enable Cortana on Windows Phone 8.1
3.8 ★ | 16 Vote