I installed 7-zip and add its directory to system path: C:\Program Files\7-Zip to PATH, from windows start->input cmd and press enter, Windows command line is started, i type 7z.exe, then press enter, it just run.

However when i start command line this way:

cmd.exe /c start cmd.exe

then i type 7z.exe, it gives me error because it can not find 7z.exe. why and how to fix?

P.S. 1. I'm on Win7. 2. For some other apps, the above way did works, that's why i'm so confused how bat works.

  • 1
    What's the bin path? Aren't you missing some quotes? – Luiz Angelo Dec 5 '12 at 10:23
  • i updated my question to let it more specific. – July Dec 5 '12 at 11:08
  • Your command line command seems strange. Why start? Why the "cmd /k" at the end? What are you really trying to accomplish? Try without the extra stuff. – Luiz Angelo Dec 5 '12 at 11:21
  • OK, extra stuff removed, see my edit above. – July Dec 5 '12 at 11:33

There are two PATHs on Windows. The user and the system.

Which one have you altered? When it doesn't work, try "ECHO %PATH%" and see if "C:\Program Files\7-zip" is there. Try running manually.

Anyway, your command is strange. It is cmd calling (and closing afterwards) start. Start calls cmd.exe again with the /K switch. The /k Switch has something to do with quotes, but I don't get it. Why do you need the sequence cmd -> start -> cmd?

  • Thanks for your comment, i did set the folder to PATH however i run "echo %path%", "C:\Program Files\7-zip" is not there. it's strange. – July Dec 5 '12 at 12:04
  • My guess then is that you've added the "C:\Program Files\7-zip" to a user path. And that this command chaining of yours dumps you in a different security context where you can't the original path. Which you see in you just type cmd. Change the system path and see if that works. – Luiz Angelo Dec 5 '12 at 12:08
  • 1
    Just now I restart my computer and now it works, Windows does not prompt me with a restart when i modify the PATH. What i would like to use the cmd is, i'd like to start it to a definite directory, so command like cmd /c start "title" /D "D:\mydir" cmd.exe /K will start cmd at D:\mydir. Thanks for your ideas and patience. – July Dec 5 '12 at 12:31
  • cmd /k "folder" is enough. Source: stackoverflow.com/questions/60904/… – Luiz Angelo Dec 5 '12 at 13:25

If you simply added bin to your PATH, not a complete path like C:\Users\July\bin, then if you type xx, cmd.exe will try to resolve that as the relative path bin\xx.exe, meaning it will look in bin subdirectory of the current directory. I suspect that's not what you expected.

  • Thanks for your input, yes i added the complete path to PATH – July Dec 5 '12 at 8:56

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.