带有驱动器盘符确认的菜单

发布于 2024-09-24 07:12:39 字数 1042 浏览 7 评论 0原文

我目前正在尝试在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尘曦 2024-10-01 07:12:39

缩进不起作用,因此在 START %D%/xosl/install.exe 之后,它将在 :NOWINDIR 处继续。

您可能想要这样做:

echo OFF
CLS
:MENU
echo .
echo ...............................................
echo                 XOSL Installer
echo ...............................................
echo .

SET /P D=Enter drive letter such as (C:):

IF EXIST %D% (
   mkdir %D%/xosl/
   xcopy /xosl/*.* %D%/xosl/
   cd %D%/xosl/
   START %D%/xosl/install.exe 
) ELSE (
   ECHO Drive does not exists
   GOTO MENU
)

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:

echo OFF
CLS
:MENU
echo .
echo ...............................................
echo                 XOSL Installer
echo ...............................................
echo .

SET /P D=Enter drive letter such as (C:):

IF EXIST %D% (
   mkdir %D%/xosl/
   xcopy /xosl/*.* %D%/xosl/
   cd %D%/xosl/
   START %D%/xosl/install.exe 
) ELSE (
   ECHO Drive does not exists
   GOTO MENU
)

PS: Try to add quotes around each variable like that "%D%". You may get only the first letter using this "%D:~0,1%:".

兔小萌 2024-10-01 07:12:39

您只需要一种在批处理文件工作时跳转到其末尾的方法,因为它也只是运行并执行 :NOWINDIR 代码 - 尝试添加以下内容:

IF NOT EXIST %D% GOTO NOWINDIR
   mkdir %D%/xosl/
   xcopy /xosl/*.* %D%/xosl/
   cd %D%/xosl/
   START %D%/xosl/install.exe
   GOTO END
:NOWINDIR
   ECHO Drive does not exists
   GOTO MENU
:END

另外,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:

IF NOT EXIST %D% GOTO NOWINDIR
   mkdir %D%/xosl/
   xcopy /xosl/*.* %D%/xosl/
   cd %D%/xosl/
   START %D%/xosl/install.exe
   GOTO END
:NOWINDIR
   ECHO Drive does not exists
   GOTO MENU
:END

also, echo. (no space between the echo and the .) will give you a blank line

青柠芒果 2024-10-01 07:12:39

而不是这个:

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

试试这个:

    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

instead of this:

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

try this:

    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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文