开发者

Asterisk (*) in windows batch file command line argument gets expanded

开发者 https://www.devze.com 2022-12-10 23:53 出处:网络
I have a batch script that takes arguments from the command line. One of the arguments has a * in it. In spite of putting the argument in quotes, the * gets expanded before the argument gets used in t

I have a batch script that takes arguments from the command line. One of the arguments has a * in it. In spite of putting the argument in quotes, the * gets expanded before the argument gets used in the batch script.

I am using the following code to parse the arguments:

set CMDLINE_ARGS=%~1
shift 
:get_args 
if "%~1" == "" goto execute
set CMDLINE_ARGS=%CMDLINE_ARGS% %~1
shift
goto :get_args

This works on Windows Server 2003 but not on 开发者_如何学GoServer 2008 for some reason.


It has been a long time since I did anything like this but take a look at

  SETLOCAL ENABLEDELAYEDEXPANSION

Not sure what Windows Server 2008 defaults to.

0

精彩评论

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