0

Suppose I installed a new package with someProgram in it: myNewPackageDir/bin/someProgram

If I want to accessing it from cmd using only its name (example: someProgram --option1 a --option2 b --option3 c), I would have to append someProgram's folder to the PATH variable: setx PATH "%path%;myNewPackageDir\bin"

I keep installing many packages on windows through winget, and everytime a new package is installed, i have to add this new program's folder path to the PATH variable so i can call it from cmd directly.

Any other way around this? Is there a better approach? My PATH variable is really long now(>1000 characters), and I don't want to keep adding every new program's directory to the PATH variable. The whole reason i add it to the PATH variable is so that i can call it directly, but this process is becoming cumbersome with more packages being installed.

So how do i call programs directly without adding it to my PATH variable?

(Also, I am using Windows 10.)

4
  • @Robert I do use \ , but i wrote / here by mistake, but that's not the point. Commented Sep 8, 2021 at 16:35
  • "So how do I call programs directly without adding it to my PATH variable?" - You create a system variable, that contains the path to the application, and then add the variable to the PATH variable. You would have a similar issue on Linux
    – Ramhound
    Commented Sep 8, 2021 at 16:44
  • Here is a nice alternative if you are attempting to do this for scripting reasons.
    – Ramhound
    Commented Sep 8, 2021 at 16:54
  • Also type doskey /?. You load your alias at Command Prompt startup by specifying a batch or command at HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor and create the AutoRun string value. Commented Sep 8, 2021 at 22:19

2 Answers 2

1

I solved it. All I wanted to achieve was being able to call someProgram.exe directly without adding it to my PATH variable. So I created a folder called C:\Shortcuts and added a shorcut to someProgram.exe: someProgram.lnk. I added this C:\Shorcuts folder to my Path variable: setx PATH "%PATH%;C:\Shorcuts" Now, from any directory, i can simply call: someProgram --option1 a --option2 b c and it will work.

From now on, i just have to drop in shortcuts to the programs i want to call directly into this new folder, and I saved a lot of characters on my PATH variable

EDIT: this doesn't work correctly all the time, for example, python doesn't work exactly the way i want it to if i am calling if from a shortcut, so i would have to add its directory to the path variable. But most of the time, it works pretty well

1
  • Also, you have to add .LNK to your pathtext variable to avoid typing .lnk everytime you are trying to call someProgram.lnk Commented Sep 11, 2021 at 3:30
0

The easiest way would be to use the start command:

start "" "SomeProgram.exe"

  • The first quotes are for the program title if you want to specify

The other method is to add the program in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

Inside "App Paths" create a key with the name of the program + extension that the user should use open the program, ex: SomeProgram.exe

Inside the "SomeProgram.exe" key create new "String Value" called "Path" and specify the path to the program there (only the path not path + prorgramname).

Ex: C:\Program Files\Techsmith\Camtasia 9\

That's it....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .