开发者

How to ignore %% from being evaluated?

开发者 https://www.devze.com 2022-12-30 20:13 出处:网络
One of my variables h开发者_如何学Cas the value %val% - this is exactly the name! So: set variable=%val%

One of my variables h开发者_如何学Cas the value %val% - this is exactly the name!

So: set variable=%val%

What happens now is that when running the script the variable will be set to nothing as the %val% is being evaluated! But this is not what I want... How can I tell DOS to ignore the %-sign here?


Use double % characters to escape a single one:

set variable=%%val%%

Look here for different kinds of escape characters.


SET variable=%%var%%

ECHO %variable%

PAUSE 

Works on my machine.


set variable="%val%"
0

精彩评论

暂无评论...
验证码 换一张
取 消