11

Is it possible to configure Windows to launch an executable from the run menu (⊞ Win+R) using a single word?

Similar to Mac OS' Spotlight Search, I would like to be able to type one word and launch an app, for example Sublime Text...

Run sublime

or, VS code...

Run code

If one word is not possible, is it possible to create an alias for the system and combine it with one other word such as start or similar?

3

8 Answers 8

18

It's certainly possible, all you need to do is to include the executable's folder in the PATH environment variable.

See for example the article How to Add to Windows PATH Environment Variable.

Note: An improvement by the poster for when the name of the program is too long to type comfortably, is to create a link with a short name for the program in the same folder, so creating an alias.

3
  • 2
    Ok, I found the application installed in the folder C:\Program Files\Sublime Text. I created a shortcut in that folder named "sublime" which points to the installed executable "sublime_text" which allows me to successfully run the application from the Run menu with one word, "sublime".
    – ThisClark
    Sep 26, 2021 at 19:21
  • 2
    based on this answer I created a folder "run", added in the path and put there shortcuts of the apps I want to run fast. This eliminates the need to constantly edit PATH as I add / change / remove stuff. Sep 29, 2021 at 8:14
  • 1
    This solution does not rely on the Windows Start Menu and the Windows Indexing Service, as both of these have plenty of quirks. This solution will always work and be available immediately.
    – harrymc
    Sep 29, 2021 at 8:22
86

Instead of using run just press the Windows key and start typing (windows will not show the search field until you start typing). Windows will search your installed programs and present you the "best" choices, which usually works pretty well.

enter image description here

You don't even have to type the full name.

7
  • 30
    This is the right answer. Don't try and botch the command line into being Mac Spotlight, use the actual equivalent. Sep 27, 2021 at 8:02
  • 16
    The real Spotlight equivalent is actually "PowerToys Run" docs.microsoft.com/en-us/windows/powertoys/run, though it needs a separate install for now. But I agree that this is the right answer to the question. Sep 27, 2021 at 9:33
  • Note that this even works with executables in the system search path (just like the ‘Run...’ dialog) even if they are not ‘in’ the star menu, though you can’t pass any arguments when invoking executables directly this way like you can with the ‘Run...’ dialog. Sep 27, 2021 at 16:55
  • 2
    You’re still on Sublime Text 2?
    – jornane
    Sep 28, 2021 at 14:51
  • 1
    TBH, I haven't used Sublime in years. I just hadn't uninstalled it yet. Sep 29, 2021 at 9:30
12

The PATH methods are all messy. You don't want to add a PATH variable for every single thing that you want to add. The system has to look through the path for stuff every single time it gets a command so it is optimal to keep the path as small as possible. Actual performance? .. who knows.. but it IS SLOWER and it is a PITA to do this for every single thing you want to be able to do this with.

The "windows search" methods are cool.. but require the extra step of ensuring that the item you want was filtered to the top of the list. I too use this method, but not for the things that I use all day and every day, and not for things that I also want access to from the command line.

Here is >MY< trick.

  1. Edit your PATHEXT environment variable to include .LNK
  2. Create a folder "somewhere" and add that folder to your PATH. I call mine "CMD" but you can call it anything you like.
  3. Drop shortcuts in that folder and rename them to simple names to type. For instance, I still use ol' Paint Shop Pro.. my lnk name is psp.lnk. I use UltraEdit and my link name is ue.lnk.
  4. For added pizzaz, edit the shortcut file and remove EVERYTHING from the "start in" field. This will allow you to be able to use the link to fire up things from both the run dialog and the command prompt. For instance.. from the command prompt, if you are in the directory with said file.. ue somefile.txt or psp mypicture.bmp. If you are in the run dialog, you will need to have the whole path to use a path on the command line.. psp c:\myimages\mrbill.jpg

I have been using this method for years now. Please note that adding .LNK to your pathext creates a potential security risk if you aren't thinking about what you are doing but the risk is worth it to me.. just think it through.

Oh.. fyi, I also put batch files in my CMD folder to perform tasks like toggling the state of groups of services and doing other menial tasks I need to do regularly. It saves me a lot of time.

7
  • I like the idea. I'll review later and respond accordingly.
    – ThisClark
    Sep 26, 2021 at 19:35
  • Handy util: schinagl.priv.at that can replace the manual items above to a right mouse click
    – edelwater
    Sep 26, 2021 at 20:59
  • You should add that although the OP can use any name he likes, if he was to use something like R&D he will need to encapsulate his command within double quotes “R&D” likewise if he was to use Research and Design it would also need to be encapsulated within “ “ I’d also try and use names that wouldn’t actually pull up a command for instance searching CMD would actually open CMD if it was followed with enter / return
    – Dan K
    Sep 27, 2021 at 11:27
  • 1
    Yeah @J... ... duhhhh.. thanks for what seemed to make sense at the time. :P Sep 27, 2021 at 19:04
  • Instead of creating all those shortcuts and modifying the PATHEXT (which I wouldn't discount could be a security problem one way or another), I'd simply put symlinks into the folder. That's pretty much what chocolatey and other package managers do. But yeah that's what I usually also do.
    – Voo
    Sep 28, 2021 at 19:39
9

Open the registry editor (Win+R, regedit, Enter), and under either of the following keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths

make a new key (right-click App Paths and choose NewKey), and name it whatever shortcut word you want followed by .exe. With that key selected, double-click "(Default)" in the right hand pane and enter the full path of the executable you want to run.

Now Win+R followed by your shortcut word (without .exe) and Enter will run that program.

This approach doesn't pollute the PATH, doesn't subject you to the vagaries of whatever Windows may think you want to find today, and doesn't require any extra software to be installed. The shortcut word needn't match the executable name.

If you do this in HKEY_LOCAL_MACHINE then it will apply to every user, while HKEY_CURRENT_USER will only apply to you. Under HKEY_LOCAL_MACHINE, you will find a lot of existing entries to pattern yours after, while under HKEY_CURRENT_USER you may not. (You may even have to create the App Paths key.)

4
  • 1
    This is the correct answer. A lot of software installed through an installer (exe or msi) creates App Paths entries.
    – iBug
    Sep 28, 2021 at 2:26
  • @iBug, IMHO there is no "correct answer". There are 100 ways to accomplish this and none of them are wrong. Oct 8, 2021 at 14:16
  • @SeñorCMasMas Some of them are certainly "more canonical" than others. This is one of them.
    – iBug
    Oct 8, 2021 at 14:49
  • @iBug.. that probably depends on your age or you work flow.. but I do appreciate your response. :) Oct 8, 2021 at 19:41
3

As @Gerald Schneider pointed out in his answer, why not just hit the Windows key and start typing. The Run dialogue is a relic of a bygone age (i.e. Windows 7, Edit: and of course earlier as pointed out by others! I just said Windows 7 as that was when it was last used extensively in day to day work). The Start menu completely surpasses and eclipses it, you just hit Windows and type immediately, do not look for a box to type into (like the Run dialogue); this is all automatic, just type and it will start making suggestions for you (unlike the Run dialogue, which gives no suggestions). I would actually ask why you are using the Run dialogue, is it possible that you went to Mac for a long time, then came back to Windows and assumed that we were still in "Windows 7-land" (this is not a criticism, I'm sure I would do the same if I went away from Windows for a long time, we use the things that we last remember!).

However, on your point around Spotlight, you have lots of options in Windows. I use the official Microsoft PowerToys for Windows 10 which includes "PowerToys Run", just install that then press Alt+Space and start typing into that dialogue (just like Spotlight). There are also 3rd party variants like Wox, Search Everything, Cerebro Pro, Launchy, or KeyPiranha (this one has an interesting 'action step' that allows you to find a command, then Tab to add options onto the command line, so you can build compound commands that might be well suited for your needs). https://docs.microsoft.com/en-us/windows/powertoys/

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – DavidPostill
    Sep 30, 2021 at 19:54
1

You can use applications like Launchy or Microsoft's own PowerToys, which offers the "Run" app. They basically extend the capabilities of quick launching for Windows.

I've personally used Launchy for many years, and you can configure specific folder you want it to look for apps to run. I am now trying PowerToys Run out, so far I am happy, although it is far less flexible.

1
  • +1 for Launchy! I have been using it for many years and prefer it's speed and customization to Windows start/search.
    – trebor
    Oct 16, 2021 at 0:55
1

The equivalent feature to Spotlight is the search feature in Windows start menu which has been there since Windows Vista. It doesn't only search executables but also files, emails, music, contacts... It can even find things that Spotlight can't like settings. And it'll sort the result based on frequency, for example if you use Notepad++ more than Notepad or MS Word more than Wordpad then those will appear first

Windows Vista start menu (Windows Vista)

Windows 7 start menu (Windows 7)

There's no reason to use the Run dialog just to run programs. Pressing Windows then type W would be faster than Windows+R then winword

In Windows 8 and up the search box might not appear at first but they still work as normally when you type any character after opening the start menu

In Windows 10 another way that can be used to search and open programs is the search box which can be activated by Windows+S. This one is linked to the Cortana so if you've signed in then it can do even more things than searching

And as said, if you prefer the Spotlight way then PowerToys already provide the same search feature when pressing Alt+Space. You can also install 3rd party start menu apps to get other ways to search

Windows 10 search

Windows 10 search

2
  • 1
    "And it'll sort the result based on frequency" well that's what people dislike, isn't it? I want same keypresses to open same software always, not only if it has had certain popularity recently.
    – Džuris
    Sep 28, 2021 at 20:22
  • 3
    @Džuris If I recall correctly, Spotlight works the same way -- By frequency. The question that was asked specifically referenced Spotlight as the example, so I'm not sure why this wouldn't be a correct answer to the OP question. Sep 28, 2021 at 20:29
0

Yes you can!

The reason its not working for you is that you don't have your executable file (.exe) inside one of the PATH variables.
Which is an environment variable that is the default path when you don't specify any directory.

So for example, when you run winver command in run, it opens windows version dialog. Behind the scene what's happening is that it first finds your command file in PATH variables. The file is found at C:\Windows\System32. It then runs it as an executable.
winver ==> C:\Windows\System32\winver.exe

The reason its not working for your applications is that they're not found in any of the PATH variables.
What you can do is make shortcuts for your applications that you run the most often to one folder and add it to one of the PATH variables. Don't forget to name the application shortcuts to a single word name.
Moving the exe file would work too but rarely as apps require dependencies found in their folder.

Consult from the following easy guide:
https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.