0

I am using Windows 10 Pro, but I'm sure the process is the same as Windows Vista through 8.1 or it's similar enough for me to figure out the minor differences.

I have two programs with the same exact named .exe file that I want to target in my path variable in system variables.

Example: Program 1's path: C:\somefolder\anotherfolder\prog.exe Program 2's path: C:\evenmorefolders\prog.exe

I can't run both just by putting their filepaths in the PATH variable because then it will only use the first one listed when I type prog in the command prompt.

I want to set one of these programs to be opened with a name other than prog. I want to be able to type say free in order to use the prog.exe of program 2.

How do I set the environment variables to do that?

0

The two simplest options (that I can think of) to do what you're trying to do don't require changing the PATH environment variable.

Option one, just to get it out of the way, you can create a Windows Shortcut and point it directly at the program you're trying to run. However, you're asking about typing at a command line, so maybe Shortcuts won't meet your requirements.

Option two, you can create a batch file to run your program.

  1. Open Notepad
  2. Type in C:\somefolder\anotherfolder\prog.exe %1 %2 %3 %4 %5 (the path and filename of your actual program)
  3. Click File > Save As...
  4. Select a location that's in your PATH environment
  5. Call it progA.bat (or whatever makes sense)
  6. Make sure to select 'All files (.)' next to 'Save as type:'

Repeat it for the other program 'C:\evenmorefolders\prog.exe' and call it progB.bat (or whatever...)

The %1, etc. will allow parameters typed in at the command line to pass to the program in the batch file.

Now, from a command line, you can type progA -a -x -t to run one of the programs or type progB /j:100 /p "whatever" /m to run the other one.

  • I had thought about that, but I wanted to be able to use command options as well, such as prog -a or prog file.txt and such as that. – Progfram Apr 16 '16 at 0:14
  • @Progfram why wouldn't you be able to use command with a batch program? – Wes Larson Apr 16 '16 at 0:16
  • Actually, I need to be able to use command options. Defeats the whole purpose if I can't use command options when using it from the command line. – Progfram Apr 16 '16 at 0:19
  • @Progfram Ah. See edits in my answer. – Wes Larson Apr 16 '16 at 0:23
  • Seems to be working great, but I'm not sure what you meant by the progB /j:100 /p "whatever" /m Are you just telling me that any of those types of conditions will work with that batch file? – Progfram Apr 16 '16 at 0:41

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.