创建了一个选择批处理文件来启动带有参数的自定义脚本:不起作用

发布于 2024-09-29 05:07:03 字数 1263 浏览 0 评论 0原文

我创建了一个脚本,该脚本将为用户提供从同一程序运行哪个操作的选择。问题是,创建我调用的程序的人设置的参数没有像 / 或 - 这样的开关。每当我运行批处理并尝试调用正确的操作时,只有可执行文件在没有参数的情况下运行,并且我尝试了多种引用和取消引用的方法。这是该批次,其中删除了一些 NDA 目录和应用程序名称,这样我就不会失去工作。

    @echo off
cls
:start
echo.

echo 1. EXPORT 
echo 2. EXPORT AP
echo 3. EXPORT CLASS ALL
echo 4. EXPORT CLASS STORE
echo 5. EXPORT PLUBATCH ALL
echo 6. EXPORT PLUBATCH STORE
echo 7. EXPORT STORE
echo 8. EXPORT TOUCH
echo 9. I'm Done
echo.
echo.
set /p x=Choose your fate:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT

:Item_2
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT AP

:Item_3
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS ALL

:Item_4
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS STORE

:Item_5
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH ALL

:Item_6
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH STORE

:Item_7
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT STORE

:Item_8
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT TOUCH

:Item_9
pause
exit

每当我运行时,比如选择 2,它只执行应用程序的通用操作,就好像我根本没有运行任何参数一样。导出显然是一个命令,第二个参数列出了您希望程序导出的内容。有什么建议吗?

I've created a script that will offer the user a choice in which action to run from the same program. The problem is, the person who created the program I'm calling set parameters that do not have switches like / or -. Whenever I run the batch and try to call the correct action, only the executable runs without the parameters and I've tried multiple ways of quoting and unquoting. Here's the batch as it stands with some NDA directory and application names taken out so I dont lose my job.

    @echo off
cls
:start
echo.

echo 1. EXPORT 
echo 2. EXPORT AP
echo 3. EXPORT CLASS ALL
echo 4. EXPORT CLASS STORE
echo 5. EXPORT PLUBATCH ALL
echo 6. EXPORT PLUBATCH STORE
echo 7. EXPORT STORE
echo 8. EXPORT TOUCH
echo 9. I'm Done
echo.
echo.
set /p x=Choose your fate:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT

:Item_2
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT AP

:Item_3
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS ALL

:Item_4
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS STORE

:Item_5
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH ALL

:Item_6
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH STORE

:Item_7
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT STORE

:Item_8
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT TOUCH

:Item_9
pause
exit

Whenever I run, say Choice 2, it only does the generic actions of the application as if I'm running no parameters at all. Export is obviously a command and the second parameter lists what you'd like the program to export. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

葬﹪忆之殇 2024-10-06 05:07:03
IF '%x%' == '%x%' GOTO Item_%x% 

应该是:

IF '%x%' == '%x%' GOTO :Item_%x% 

让我们尝试一个更简单的例子:

@echo off 
cls 
:start 
echo. 

echo 1. Do something.
echo 2. Do something else.
echo 3. Quit
echo. 

set /p x=Choose your fate: 
goto :Item_%x

goto :eof

:Item_1 
echo Doing something.
goto :start

:Item_2 
echo Doing something else.
goto :start

:Item_3 
echo Quitting.
goto :eof
IF '%x%' == '%x%' GOTO Item_%x% 

Should be:

IF '%x%' == '%x%' GOTO :Item_%x% 

Let's try a simpler example:

@echo off 
cls 
:start 
echo. 

echo 1. Do something.
echo 2. Do something else.
echo 3. Quit
echo. 

set /p x=Choose your fate: 
goto :Item_%x

goto :eof

:Item_1 
echo Doing something.
goto :start

:Item_2 
echo Doing something else.
goto :start

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