Cortana, the digital assistant that comes with Windows 10, is Microsoft’s answer to Apple Siri and Google Now. It is quite capable, but there are times when I wish it has more features. For example, I really wanted to be able to lock my computer with a single voice command, but Cortana does not have this function built in. Fortunately, it is possible to extend Cortana’s function. To do so, we make use of the fact that Cortana searches through the start menu shortcuts when you say the keyword “open” or “launch”.
Here are the steps to create a command to lock your computer:
1. Create a shortcut in an accessible location such as the desktop. This can be achieved by pressing the right mouse button and select [New]->[Shortcut].
2. For the location of the item, enter: %SystemRoot%\System32\rundll32.exe user32.dll,LockWorkStation
3. Give the shortcut a natural name, which is what Cortana will look for when you speak to her. Since Cortana utilitizes natural language processing, it is much better at recognizing phrases that actually make sense.
4. Copy the newly created shortcut to: %SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs. You will need administrative privileges to complete this step.
If all goes well, you should be able to lock your computer by saying “hey Cortana, open lock computer”.
You can create similar commands to hibernate or sleep your computer. Just change the location of the item accordingly:
Hibernate: %SystemRoot%\System32\rundll32.exe Powrprof.dll,SetSuspendState Sleep
Sleep: You need PSTools from Microsoft (https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx). Set item location as: [Location of PSTools]\psshutdown.exe -d -t 0
Another thing you can do is to create a command to open a website. You might think that this would be as simple as adding an internet shortcut to the start menu, but turns out it is more complicated than that: while Cortana keeps a record of internet shortcuts created through installation of programs, she does not do so with ones that are added manually. Furthermore, she does not index shortcuts that have non-executable extensions, meaning that you cannot use “chrome.exe gmail.com”, because this would be recognized as having a “.com” extension.
Here is how to get around this issue:
1. Create a text file and type in it “start ” followed by the URL you want to open.
2. Change the extension of the text file to “.bat”
3. Create a shortcut that points to the file you just created and follow the aforementioned steps.
For example, I have created a shortcut called “Gmail” that points to a “Gmail.bat” that executes “start http://www.gmail.com”. With this, Cortana would open Gmail with my computer’s default browser when I say “Hey Cortana, open Gmail”.
Upon creating the shortcuts, you might notice that the default icon is quite uninformative. You can pick a better one after you created the shortcut by right-clicking on the icon, click [Properties], followed by clicking [Change Icon…]. Enter one of the following in “Look for icons in this file” textbox, where you should find a lot of icons to choose from:
%SystemRoot%\System32\shell32.dll
%SystemRoot%\System32\imageres.dll
So here you go, try it out!