如何在批处理文件中使用启动命令

时间:2016-12-22 19:33:55

标签: batch-file

好吧,好吧,我想制作类似操作系统的东西...但是当我启动.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

现在的捷径:
This is an image

所以......我希望屏幕截图中的命令能够在代码中执行......

1 个答案:

答案 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

读取参数