开发者

how to assign an ip address to a variable in batch

I have assigned i开发者_如何学Pythonp address to a variable in the following way.

  set /A myvar = 10.0.0.1
  echo %myvar%

but it is giving the result as only 10 not entire ip address.. so can some give the solution for it


try this:

set myvar=10.0.0.1 
echo %myvar% 

The /A switch specifies that the string to the right of the equal sign is a numerical expression that is evaluated. The expression evaluator Note: no spaces around "=" sign


Just don't use /A, its for numerical expressions

set myvar=10.0.0.1
echo %myvar%
//10.0.0.1


Get rid of the /A, then it will work.

C:\>help set
[...]
The /A switch specifies that the string to the right of the equal sign
is a numerical expression that is evaluated.
[...]


Can you put quotation marks around the ip address? "10.0.0.1"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜