Skip to content

Instantly share code, notes, and snippets.

@cxfksword
Last active April 8, 2017 09:34
Show Gist options
  • Save cxfksword/3ccde3817a8b88f23d74 to your computer and use it in GitHub Desktop.
Save cxfksword/3ccde3817a8b88f23d74 to your computer and use it in GitHub Desktop.
windows命令行常用功能

获取当前执行bat的目录

echo %~dp0

进入执行bat目录

cd /d %~dp0

获取当前工作目录

echo %cd%

查找指定程序所在路径

for /f %%i in ('where php') do set RESULT=%%i
echo %RESULT%

bat中获取命令行参数

"%PHPBIN%" %*

判断命令执行结果是否包含指定字符串

vagrant box list|find "centos-5.8"
if errorlevel 1 (
    echo not exist
) else (
    echo exist
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment