0

How does application (any) make its shortcut for launch in installation? For example c:\>start calc will launch windows calculator, but I have no idea where is located the executable calc.exe and how did the application make a shortcut for it (so it could be used as a argument to start command). Another example c:\>start gcc foo.c will trigger the gcc compiler (installed from mingw), but how does start command know where to find its executable? I know the cmd.exe will look in %PATH%, which in my case is C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\ppast\AppData\Local\Microsoft\WindowsApps;C:\Users\ppast\.dotnet\tools;C:\Users\ppast\OneDrive\Plocha\scripts;

But for example - if I trigger c:\windows\system32> cl foo.c gives:

'cl' is not recognized as an internal or external command,
operable program or batch file.

gives error. But I know I have the windows compiler installed (since I have visual studio c++ installed).

So how does application makes shortcuts (and how to find out, which shortcut/name should I use as argument for start when I know application name) ? And how to make custom shortcut for my own exe files?

Herdsman
  • 331
  • 1
  • 4
  • 10
  • This lists `shell:` folders. Paste into command prompt. `(@For /f "tokens=1* delims=" %A in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion‌​\Explorer\FolderDesc‌​riptions /f name /v name /s ^| findstr /c:"Name" ^| Sort') Do @Echo %A) & pause`. EG in Start Run Dialog `Shell:Startup` or at command prompt `start shell:startup`. – Mark Jul 23 '20 at 22:55
  • This lists Modern App URLs - a way of starting them no matter what the version is. `(@For /f "tokens=1* delims=" %A in ('reg query HKCR /f "URL:*" /s /d ^| findstr /c:"URL:" ^| findstr /v /c:"URL: " ^| Sort') Do @Echo %A %B) & pause` EG in Start Run dialog `calculator:\\ ` or command prompt `start calculator:\\ `. – Mark Jul 23 '20 at 22:57
  • This list app you can start by typing their name in Run dialog or by using command prompt's Start command. `(@For /f "tokens=7* delims=\" %A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" /f "*" /k') Do @Echo %A) & pause`. EG `write` or `start write`. – Mark Jul 23 '20 at 23:00
  • Also `dir c:\windows\*.exe c:\windows\system32\*.exe /a` will show starter apps for programs like calc. – Mark Jul 23 '20 at 23:02

1 Answers1

0

Windows stores paths to folders with executables as Environment Variables. If you are running Windows 10, navigate to System Properties > Advanced > Environment Variables. Under System Variables you'll notice a variable called Path. Highlight this variable and select edit. Here, you can add the path to a folder containing your own personal executables by pressing New. For example, you should see a folder:

%SystemRoot%\system32

If you enter the file explorer and type in that address, you will be brought to the folder, and sure enough calc.exe is within it. Essentially what happens in cmd is Windows searches all of the folders in this Path variable to see if any of them contain the executable you are looking for. If it's in one of them, then the program will start. So, if you create a new folder

C:\my_executables\

and add this value to the Path variable, you will be able to store any executables that you want there.

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
Kraigolas
  • 343
  • 2
  • 10