Windows 中的命令 cd/d %~dp0 是什么意思 [英] What does it mean by command cd /d %~dp0 in Windows

查看:58
本文介绍了Windows 中的命令 cd/d %~dp0 是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我理解命令 cd/d %~dp0 及其用途.再次 dos 命令在下面

Can someone please help me to understand the command cd /d %~dp0 and its purposes. Again dos command is below

cd /d %~dp0

请帮助我理解它的含义.

Please help me to get the meaning of it.

推荐答案

我们来剖析一下.分为三部分:

Let's dissect it. There are three parts:

  1. cd -- 这是更改目录命令.
  2. /d -- 此开关使 cd 一次更改驱动器和目录.没有它你将不得不做 cd %~d0 &cd %~p0.(%~d0 更改活动驱动器,cd %~p0 更改目录).
  3. %~dp0 -- 这可以进一步分解为三个部分:
  1. cd -- This is change directory command.
  2. /d -- This switch makes cd change both drive and directory at once. Without it you would have to do cd %~d0 & cd %~p0. (%~d0 Changs active drive, cd %~p0 change the directory).
  3. %~dp0 -- This can be dissected further into three parts:
  1. %0 -- 这表示批处理脚本的第零个参数.它扩展为批处理文件本身的名称.
  2. %~0 -- ~ 在扩展参数周围去掉双引号 (").
  3. %dp0 -- dp 有扩展的修饰符.d 强制添加驱动器号,p 添加完整路径.
  1. %0 -- This represents zeroth parameter of your batch script. It expands into the name of the batch file itself.
  2. %~0 -- The ~ there strips double quotes (") around the expanded argument.
  3. %dp0 -- The d and p there are modifiers of the expansion. The d forces addition of a drive letter and the p adds full path.

这篇关于Windows 中的命令 cd/d %~dp0 是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆