T
T
to2n2018-10-06 14:10:06
cmd/bat
to2n, 2018-10-06 14:10:06

How does the SET command work in the windows console?

1. Why does the command not output the added path to the console? Only the initial state of the PATH variable

cmd /C "set PATH=C:\Qt\5.9.1\mingw53_32\bin;%PATH% && echo %PATH%"

2. Why, with such a launch, the application swears that it did not find the libraries that lie along the added path
cmd /C "set PATH=%PATH%;C:\Qt\5.9.1\mingw53_32\bin && reactNativeDesktop.exe"

And if you rearrange the added path to the beginning, then the program starts correctly
cmd /C "set PATH=C:\Qt\5.9.1\mingw53_32\bin;%PATH% && reactNativeDesktop.exe"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-10-06
@to2n

1. Because that's how cmd.exe works - it's not the set command's fault.
The fact is that cmd.exe processes batch files line by line.
It takes the next line from the file as a whole, before executing it, it dereferences the variables, i.e. inserts the contents of the variable directly into the command and only then executes the command.
Therefore, the effect that you described appears.
In your case, there is no batch file, but cmd.exe treats the string passed to it as a single command and works with it in the same way as with the batch file string.
You can get around this by simply dropping echo %PATH% on a separate line, but this will require you to create a batch file.
But in your case, such a change in the PATH variable will not give you anything, because the action of the set command will only be relevant within the current cmd.exe execution session.
2. It would be good to see how specifically the program swears.
It seems to me that in the first case, she finds some similar libraries that are in a different place (registered in PATH), but they do not suit her - a different version or they are generally left, they are simply called the same.
In the second case, the search starts immediately from the desired directory and the required libraries are found.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question