How to run a custom task in Windows 10 with Cortana
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 .
3. Open the Run window .
4. File Explorer will open, displaying the folder ' Start Menu> Programs '.
5. Right-click an empty area, select New and select Shortcut .
6. When you have finished entering the path, just click the Next button.
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:
- Right-click any program or script you want to create a shortcut.
- You will see the context menu appear. Please select the option ' Create shortcut '.
- You should now see a new shortcut with the program or script.
- Right click on that shortcut, select ' Rename ' from the options list.
- 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.
- Now press Win + R key and you will see the Run window appear.
- Enter shell: programs in the window and click the OK button.
- You will see File Explorer with the folder ' Start Menu> Programs '.
- Now cut the shortcut created in step 2 and paste it into this folder.
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.
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
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.
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 .
Troubleshoot
Cortana cannot find or open a shortcut
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:
- Completely disabling virtual assistant Cortana on Windows 10
- 18 useful commands you should try with Cortana
- Enable Cortana on Windows Phone 8.1
You should read it
- Instructions to turn on Cortana and use this virtual assistant on Windows 10
- Use and configure Cortana on Windows 10
- How to use Cortana to turn off or restart Windows 10?
- The best setup guide for Cortana on Windows 10 (Part 1)
- The best setup guide for Cortana on Windows 10 (The last part)
- What is Cortana? How to use Cortana on Windows 10
- Why is it disabled but Cortana still runs in the background?
- How to change the language for Cortana in Windows 10
- How Cortana on Windows 10 works
- Addresses an issue where Cortana is disabled on Windows 10
- How to turn off Cortana on Windows 10 - How to turn off Cortana on Windows 10
- First look at Cortana on Windows 10
Maybe you are interested
How to add Shutdown desktop shortcut in Windows 11
Keyboard shortcuts in Excel 2007, 2013, 2016, 2010, 2003, 2019, 2021
What can the shortcut Ctrl + E in Excel do?
What is the use of the shortcut Ctrl + Z on Windows? Definitely more than you think
The shortcut file cannot be opened, what should you do?
6 Ways to take screenshots of Windows 11 with extremely easy keyboard shortcuts