0

I am building virtual directories for a setup using the following:

echo "Current Drive: %~d1"
set /p var cdr="Enter Install Directory "
cd %windir%\system32\inetsrv
appcmd add vdir /app.name:"Default Web Site/" /path:/cms /physicalPath:"%cdr%:\websites\cms"

If I manually enter the drive letter instead of use cdr everything works fine. The problem I am having is that nothing is displaying. Including %~d1 is empty cdr is empty even after being set.

Im guessing I am just completely missing something here but I dont know what.

4

1 回答 1

3

这有两个变量名。

set /p var cdr="Enter Install Directory "

尝试这个:

set /p "cdr=Enter Install Directory "

顺便说一句,你也是这个意思吗?%~d1 使用命令行上的第一个参数。

echo "Batch file is on Drive: %~d0"

这将为您提供当前驱动器:

echo "The current drive letter is %cd:~0,1%"
于 2013-06-12T15:23:48.177 回答