2

I have created a key(for example myapp.exe) under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" with below values in registry.

(Default) --> C:\Program Files\folder1\folder2\myapp.exe

Path --> C:\Program Files\folder1\folder2\;

Then I opened a command prompt and tried to open my application. But I am getting an error like "'myap.exe' is not recognized as an internal or external command,operable program or batch file."

If I add the directory where my application resides to Path environment variable, then I am able to run the application successfully from command prompt. please let me know where I went wrong.

McClane
  • 71
  • 1
  • 6
  • http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121%28v=vs.85%29.aspx has some info. The PATH statement or a batch file on the path are normal ways to get a command working to launch a program from the command prompt. – foxidrive Jan 28 '14 at 12:38
  • I gone through that link and found that "By registering our application under the App Paths key, users can start our application from Explorer's Run dialog by entering just the EXE's filename and no path". And also found that we can launch our application by registering it under App Paths from command prompt as "start myapp.exe". Is it the only way of running our applications from command prompt? – McClane Jan 29 '14 at 04:13
  • I want to know, Does the two ways (registering an application under app paths & adding EXE's directory to Path env variable) gives the same functionality when we are running our application from command prompt? – McClane Jan 29 '14 at 04:26
  • 1
    As the documentation states, App Paths works for the Run dialog. The command prompt is not the Run dialog. The command prompt follows different rules. – Raymond Chen Jan 29 '14 at 07:38
  • Thanks Raymond for clearing things up. So we can't run an application from command prompt by registering it under App Paths. To run from command prompt we need to add EXE's directory to PATH environment variable. – McClane Jan 29 '14 at 10:47
  • This link has the solution to my question. http://stackoverflow.com/questions/3114618/adding-a-application-specific-paths-so-it-works-from-the-command-line-in-window – McClane Jan 30 '14 at 04:55

1 Answers1

0

This is another way to start an application from the command prompt.

Create a batch file similar to the following and call it FR.BAT which is short for foxit reader in this example, and store the FR.BAT file in c:\windows or another directory on the PATH.

When you open a CMD prompt and type fr then it will launch this batch file and start the application.

@echo off
start "" "c:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe" 

Just be careful not to use a name which is the same as an existing Windows command.

foxidrive
  • 40,353
  • 10
  • 53
  • 68