In windows, we can start command line via start menu [start menu >> All Programs >> Accessories >> 'Command Prompt' or just type in cmd.exe start edit box for that matter]

The 2nd way is directly from file explorer. Hold shift key down, right click in a folder and select 'Open command window here'.

Why are these two different sometimes? I mean the paths are different and for that reason sometime things work in one command prompt but will not work in the other!

For example I just installed doxygen. If I invoke command prompt via start menu, it is recognized and the doxygen command works. If I invoke it through file explorer, this command is not recognized.

I am sure this has bitten me before as well when my ssh session will work in one command prompt but not the other!

Why is there a difference and what actually is this difference? Can we make both use the same environment?

  • Have you changed the path since installing doxygen? Any new cmd shell should pick up the new environment. You may have to restart explorer to also pick up the new environment. Run set in both cases to see if there is a difference. – DavidPostill Jan 8 '16 at 21:16
  • @DavidPostill I think this might be the correct answer. After I killed all instances of explorer and restarted it, it did recognize the command. If you put this in answer, I will accept it as answer. – zar Jan 8 '16 at 22:08
  • What things specifically work in one and not the other? Update your question do not post a comment. – Ramhound Jan 8 '16 at 22:42
  • @Ramhound do you expect me to spend a week and figure out what works and what not? It can be literally unlimited things to test :) I have already said what doesn't work. – zar Jan 8 '16 at 22:45
  • @zadane It is as I expected. I have added an answer. – DavidPostill Jan 8 '16 at 23:12

Why is there a difference and what actually is this difference?

If you have changed the environment (for example changing the Path after installing doxygen) then any new instance of a cmd shell would pick up the new environment.

On the other hand explorer will need to be restarted to pick up the new environment (as it inherits the environment passed to it when it was started).

If you run set in the two different command shells (one started from the start menu, and the other from "Open command window here") then you will see the difference (before and after the changes) in the two environments).

I expect you will find that doxygen is in the Path for one and not for the other.

  • I tried this on my home PC now and strangely enough I didn't have to restart explorer and doxygen worked in both command prompts right after I installed doxygen. Maybe I have full privileges on home PC? Maybe there are corporate rules setup on work machine? Don't know. – zar Jan 9 '16 at 5:33

The link in the start menu is a shortcut in which you can e.g. define admin privileges. When you go via the .exe, you have to right click and "run as admin".

  • It doesn't do anything with admin privileges. – zar Jan 8 '16 at 22:08
  • @zadane - Your question, asks what the difference between the two actions, this is the difference. – Ramhound Jan 8 '16 at 22:41
  • I meant in the environment, it's obvious the initial starting directories are different. – zar Jan 8 '16 at 22:43
  • Update your question so that is clear. – Ramhound Jan 8 '16 at 23:10

If you look at the properties of that shortcut (Start -> Accessories -> Command Prompt) you will see that it has %HOMEDRIVE%%HOMEPATH% written in "Start in", which is why it starts there instead of C:\Windows\system32. Also notice that "Run as administrator" is not selected by default.

That command is not recognized probably because it requires administrator priviliges.

  • It doesn't do anything with admin privileges. – zar Jan 8 '16 at 22:08

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.