带有驱动器盘符确认的菜单
我目前正在尝试在Windows之前启动的dos下执行批处理脚本
我正在尝试加载包含启动扇区的img文件以从闪存盘启动到“可启动软盘”并执行名为installer.bat<的批处理文件/code>
当批处理文件运行时,它应该要求技术人员验证驱动器号,然后批处理脚本会将名为 xosl
的文件夹复制到该特定硬盘驱动器,即 C:\xosl\
这是我到目前为止所拥有的:
echo OFF
CLS
:MENU
echo .
echo ...............................................
echo XOSL Installer
echo ...............................................
echo .
SET /P D=Enter drive letter such as (C:):
IF NOT EXIST %D% GOTO NOWINDIR
mkdir %D%/xosl/
xcopy /xosl/*.* %D%/xosl/
cd %D%/xosl/
START %D%/xosl/install.exe
:NOWINDIR
ECHO Drive does not exists
GOTO MENU
问题是它不断迭代,这就是为什么我认为我在 SET /P
中出错了。 .我做错了什么?
更新:
这就是我得到的..
...............................................
XOSL Installer
...............................................
Unable to create directory
Invalid directory
Invalid directory
Syntax Error
A:\>
并且它没有要求我设置目录?
Im currently trying to execute a batch script under dos thats being booted before windows
Im trying to Load the img file containing the boot sectors to boot into a "bootable floppy" from flash disk and execute a batch file called installer.bat
When the batch file is run it should ask a the technician to verify a drive letter, and then the batch script will copy over a folder called xosl
to that particular hard drive, i.e. C:\xosl\
This is what I have so far:
echo OFF
CLS
:MENU
echo .
echo ...............................................
echo XOSL Installer
echo ...............................................
echo .
SET /P D=Enter drive letter such as (C:):
IF NOT EXIST %D% GOTO NOWINDIR
mkdir %D%/xosl/
xcopy /xosl/*.* %D%/xosl/
cd %D%/xosl/
START %D%/xosl/install.exe
:NOWINDIR
ECHO Drive does not exists
GOTO MENU
The issue is it keeps iterating over and over again, this is why i think im going wrong within the SET /P
... what am i doing wrong ?
Update:
This is what im getting..
...............................................
XOSL Installer
...............................................
Unable to create directory
Invalid directory
Invalid directory
Syntax Error
A:\>
And its not asking me to set a Directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
缩进不起作用,因此在
START %D%/xosl/install.exe
之后,它将在:NOWINDIR
处继续。您可能想要这样做:
PS:尝试在每个变量周围添加引号,例如
"%D%"
。使用此"%D:~0,1%:"
可能只获得第一个字母。Indentation has no effect so after
START %D%/xosl/install.exe
it'll continue at:NOWINDIR
.You may want to do that:
PS: Try to add quotes around each variable like that
"%D%"
. You may get only the first letter using this"%D:~0,1%:"
.您只需要一种在批处理文件工作时跳转到其末尾的方法,因为它也只是运行并执行
:NOWINDIR
代码 - 尝试添加以下内容:另外,
echo.
(echo
和.
之间没有空格)会给你一个空行You just need a way to jump to the end of the batch file when it works, as it's just running through and executing the
:NOWINDIR
code as well - try adding the following:also,
echo.
(no space between theecho
and the.
) will give you a blank line而不是这个:
试试这个:
instead of this:
try this: