1

I'm attempting to add VLC to the PATH variable on a Windows 7 setup, so that it can be called from cmd using vlc vs "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe".

Using set, the PATH can be modified for the current instance of cmd, but I'd like this to persist through reboots, be applicable for all users on the system (if possible), and to use CLI tools native to Windows 7. I tried setx (in both non-admin and run-as-administrator cmd windows) as referenced in this question, and rebooted. However, after running path, the vlc path doesn't show up (in the variable string), and vlc returns the error: 'vlc' is not recognized as an internal or external command, operable program or batch file.

Here are some snippets from the run-as-admin cmd.exe instance after reboot ... I check the path:

C:\Windows\system32>path
PATH=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\pkg-vc10-x64\GeographicLib-1.23\bin;C:\Program Files (x86)\XPlan\system;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\python27;C:\python27\scripts;C:\Program Files (x86)\QuickTime\QTSystem\

I don't see the VLC path there, so I try setx again...

C:\Windows\system32>setx PATH=%PATH%;"C:\Program Files (x86)\VideoLAN\VLC"
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s). Type "SETX /?" for usage.

Looking at the PATH, I see...

  • PATH=C:\ProgramData\Oracle\Java\javapath
    • C:\Windows\system32
    • C:\Windows
    • C:\Windows\System32\WindowsPowerShell\v1.0\
    • C:\Program Files\Intel\WiFi\bin\
    • C:\Program Files\Common Files\Intel\WirelessCommon\
    • C:\strawberry\c\bin
    • C:\strawberry\perl\site\bin
    • C:\strawberry\perl\bin
    • C:\pkg-vc10-x64\GeographicLib-1.23\bin
    • C:\Program Files (x86)\XPlan\system
    • C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
    • C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
    • C:\python27
    • C:\python27\scripts
    • C:\Program Files (x86)\QuickTime\QTSystem\

... and checking in a regular-user cmd window, the results below ...

  • PATH=C:\ProgramData\Oracle\Java\javapath
    • C:\Windows\system32
    • C:\Windows
    • C:\Windows\System32\Wbem
    • C:\Windows\System32\WindowsPowerShell\v1.0\
    • C:\Program Files\Intel\WiFi\bin\
    • C:\Program Files\Common Files\Intel\WirelessCommon\
    • C:\strawberry\c\bin
    • C:\strawberry\perl\site\bin
    • C:\strawberry\perl\bin
    • C:\pkg-vc10-x64\GeographicLib-1.23\bin
    • C:\Program Files (x86)\XPlan\system
    • C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
    • C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
    • C:\python27
    • C:\python27\scripts
    • C:\Program Files (x86)\QuickTime\QTSystem\
    • C:\Ruby22-x64\bin
    • C:\Windows\system32
    • C:\Windows
    • C:\Windows\System32\Wbem
    • C:\Windows\System32\WindowsPowerShell\v1.0\
    • C:\Program Files\Intel\WiFi\bin\
    • C:\Program Files\Common Files\Intel\WirelessCommon\
    • C:\strawberry\c\bin
    • C:\strawberry\perl\site\bin
    • C:\strawberry\perl\bin
    • C:\pkg-vc10-x64\GeographicLib-1.23\bin

Why can't I add a path variable to PATH via setx? The error says the string is already there, and yet doesn't show it for either admin or standard user...

Edit to add: I also referenced this question in my original research: https://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows

6
  • Please show the code that uses setx
    – EBGreen
    Sep 4, 2015 at 20:18
  • Do you mean the second blockquote? (setx PATH %PATH%;"C:\Program Files (x86)\VideoLAN\VLC") Sep 4, 2015 at 20:20
  • @user3.1415927 That's not what is in your blockquote. See my answer. There are two mistakes in your setx command.
    – DavidPostill
    Sep 4, 2015 at 20:28
  • @user3.1415927 Note that both the links you refer to show the correct usage of setx
    – DavidPostill
    Sep 4, 2015 at 20:33
  • @DavidPostill, Good catch - I've been trying this all day, and missed my subtraction of the = at some point earlier. I had caught my error there, but stackoverflow.com/posts/9546345/revisions has an error, and is the most upvoted answer from my edit-to-add reference. (stackoverflow.com/posts/28778358/revisions, the third-most upvoted answer at this time has correct syntax.) {The first reference question has proper syntax, I just missed it there.} Sep 4, 2015 at 20:49

1 Answer 1

2

Why didn't SETX update my PATH

C:\Windows\system32>setx PATH=%PATH%;"C:\Program Files (x86)\VideoLAN\VLC" ERROR: Invalid syntax. Default option is not allowed more than '2' time(s). Type "SETX /?" for usage.

Your setx syntax is wrong:

  • Get rid of the =

    set uses =, setx does not.

  • Put the quotes " around the second parameter (the 'value').

    The second parameter should be quoted if it contains spaces and %PATH% always contains spaces.

You should be using:

setx PATH "%PATH%;C:\Program Files (x86)\VideoLAN\VLC"

Syntax

SETX [/s Computer [Credentials]] Variable Value [/m]

SETX [/s Computer [Credentials]] [Variable] /k RegistryPath [/m]

SETX [/s Computer [Credentials]] /f FileName {[Variable] {/a L,T | /r oL,oT "SearchString"} [/m] | /x} [/d Delimiters]

Source setx


Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • setx - Set environment variables permanently, SETX can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU).
1
  • Thank you, accepting your answer. I missed the "" in the referenced questions. To make sure I understand correctly, it could be said "set the PATH variable to "(the_current_PATH_variable concatenated with ';addedString')"?... Sep 4, 2015 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .