如何在批处理文件中测试当前驱动器号? [英] How do I test the current drive letter in a batch file?

查看:63
本文介绍了如何在批处理文件中测试当前驱动器号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个批处理文件,该批处理文件将使用从中运行该批处理文件的驱动器号,并将其用作IF语句.例如,如果字母是M :,它将跳到标签:mSection.

I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection.

这有可能吗?

推荐答案

您可以使用%〜d0获取驱动器号. 像这样:

You can use %~d0 to get the drive letter. Something like this:

IF "%~d0"=="M:" CALL :mSection

这篇关于如何在批处理文件中测试当前驱动器号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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