好吧,好吧,我想制作类似操作系统的东西...但是当我启动.bat
文件时,有一个set
选项可以帮助和转到GUI。我有-gsys32
的快捷方式 - 直接启动命令。 Brhfd ......看看代码,我留下一些评论。
@ECHO off
echo GraphicalSystem
echo All rights reserved! 2016
echo PLEASE WRITE help TO OPEN THE HELP WINDOW!
set /p command=
if %command% ==help goto help
if %command% ==gsys32 goto interface
cmd /k
:help
cls
echo gsys32 - Open the graphical interface.
echo exithelp - exit the help
set /p command=
if %command% ==exithelp goto start
cmd /k
:interface
cls
color 17
@ECHO OFF
echo PROGRAMS - GSYS32
echo DRIVE A:\
dir
@ECHO OFF
echo *Write dir /name of the directory without the slashes/*
cmd /k
:start
cls
@ECHO off
echo GraphicalSystem
echo All rights reserved! 2016
echo PLEASE WRITE help TO OPEN THE HELP WINDOW!
set /p command=
if %command% ==help goto help
if %command% ==gsys32 goto interface // I want this to be executed with the shortcut.
cmd /k
所以......我希望屏幕截图中的命令能够在代码中执行......
答案 0 :(得分:1)
似乎只是代码的一部分,所以很难分辨。
set "command=%1"
if not defined command goto noparms
if /i "%command%"=="gsys" goto interface
if /i "%command%"=="help" goto help
echo parameter "%1" not recognised&pause
rem don't know what you want to do now...
...
:noparms
rem there were no parameters supplied
....your posted code
%1
访问提供给例程的第一个参数。
如果要将-gsys
检测为参数,则需要gsys
代替-gsys
。匹配是文字的(/i
选项使其不区分大小写)
这是windows惯例,switch-parameters使用格式/gsys
- 但这是一个惯例,而不是规则。
set /p "var=Promptstring"
是接受键盘输入的一般形式。使用%1
.. %9