Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to set an environment variable to point to the directory into which I have extracted the latest version of OpenCV, following the instructions in OpenCV's Installation in Windows tutorial.

Here's my elevated command line listing.

C:\>cd C:\OpenCV2.4.6\build\x64\vc11

C:\OpenCV2.4.6\build\x64\vc11>cd ../../../..

C:\>setx -m OPENCV_DIR C:\OpenCV2.4.6\build\x64\vc11

SUCCESS: Specified value was saved.

C:\>cd %OPENCV_DIR%
The system cannot find the path specified.

C:\>echo %OPENCV_DIR%
%OPENCV_DIR%
  1. Firstly I change directory to C:\OpenCV2.4.6\build\x64\vc11 to ensure that it exists.
  2. After that is successful I change directory back to the root of the C drive.
  3. Then I use setx to make OPENCV_DIR a system wide environment variable with value the C:\OpenCV2.4.6\build\x64\vc11 path I verified in step 1.
  4. Noting the success of setx in the previous step I now change directory using the new environment variable. But it fails with the message The system cannot find the path specified.
  5. If I try to echo the value of the OPENCV_DIR environment variable it appears not to be set.

Looking in the control panel the OPENCV_DIR environment variable looks correctly set:

OPENCV_DIR environment variable in the control panel screenshot

What's wrong? Why is the variable not working? Am I evoking it incorrectly when I use it to change directory or echo its value?

share|improve this question
    
<clutchingatstraws>I'm going to try restarting the PC - I haven't tried that.</clutchingatstraws> –  dumbledad Oct 10 '13 at 9:52
add comment

2 Answers

up vote 2 down vote accepted

Next time just try to close and reopen the process (hehe what a cliche...)

The reason is that once a process is launched, all the variables are being written to its own address space.

If you are changing the User \ System variables - the open cmd.exe (for example) won't get the new values, but a new cmd.exe process will...

gl,

Refael

share|improve this answer
add comment

Restarting the PC fixed the problem!

C:\windows\system32>cd %OPENCV_DIR%
C:\OpenCV2.4.6\build\x64\vc11>echo %OPENCV_DIR%
C:\OpenCV2.4.6\build\x64\vc11
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.