1

I'm using setx to set a Environment variable.

My command is

setx -m PSR_NLC_FILE "%PROGRAMFILES(x86)%\Test Folder\"

But when i check on my system is set to

C:\Program Files (x86)\Test Folder"

The path is not found because of the quote.

When i use this command for another Environment variable is set correct without quote.

setx -m PSR_NLC_FILE "%PROGRAMFILES(x86)%\Test Folder\File.lic"
C:\Program Files (x86)\Test Folder\File.lic

Can someone explain to me what i'm doing wrong?

Sinista
  • 87
  • 1
  • 2
  • 10

2 Answers2

2

Look here

Some commands (e.g. REG and FINDSTR) use the standard escape character of \ (as used by C, Python, SQL, bash and many other languages.) The \ escape can cause problems with quoted directory paths that contain a trailing backslash because the closing quote " at the end of the line will be escaped \".

In your case another backslash should do the trick

setx -m PSR_NLC_FILE "%PROGRAMFILES(x86)%\Test Folder\\"

Eugene
  • 66
  • 4
1

Don't provide the trailing backslash in your command. It's not necessary for the path name to be interpreted correctly.

The modified command would look like this:

setx -m PSR_NLC_FILE "%PROGRAMFILES(x86)%\Test Folder"
I say Reinstate Monica
  • 3,132
  • 7
  • 28
  • 52