【发布时间】:2017-01-27 16:35:05
【问题描述】:
我正在创建一个非常简单的批处理脚本,用于根据用户输入映射驱动器并首先检查驱动器是否不存在。
@echo off
:EnterInfo
set /P path=Please Enter The Path You Want To Map(EG: \\server\folder)
set /P z=Please Chose A drive Letter To Map.(EG Z)
goto :CheckExist
:CheckExist
%z%:\
pause
if exist %z%:\ (
set /P Sure=A Drive Is Already Using Drive Letter %path%:\ Are You Sure You Want To Replace It?[Y/N]
if /I "%Sure%" EQU "Y" goto :SetDrive
if /I "%Sure%" EQU "N" exit)
goto :SetDrive
:SetDrive
C:
dir
net use z: "%path%"
pause
这是目前为止的代码。 我收到一个错误:'net' 未被识别为内部或外部命令, 当脚本到达 (Net use Z: "%path%") 虽然如果我要在 cmd 窗口中运行该命令的输入将起作用。
我已经检查了脚本的位置,它是从 C:\Users\%username%\ 运行的,就像 cmd 框也会默认它的位置一样。 我真的很困惑为什么它不能识别网络使用。提前致谢
【问题讨论】:
标签: windows batch-file command-line