整理.BAT 文件

发布于 2024-11-19 23:21:26 字数 493 浏览 6 评论 0原文

我的下面的脚本运行正常,但基本上我希望 .bat 在输入赌场名称和用户名之前询问用户是否想要赌场列表,然后,如果他们选择 l (小写字母 EL) 代表列表,它生成赌场列表。当前收到“转换退出值时出错”。谁能告诉我这个的代码吗?

@echo off
osql -STEMP7 -E -dAAMS888 -w256 -qEXIT("SET NOCOUNT ON SELECT casino_desc from casino") -b

set /p var1= Enter Casino Name : 
set /p var2= Enter Screen name : 

osql -STEMP7 -E -dAAMS888 -w256 -QEXIT("DECLARE @r int EXEC @r = usp_AddToObservationtbl '%var1%','%var2%' SELECT @r") -b -oc:\bat\observation.log
exit errorlevel

I have the script below which is performing correctly, but basically I want the .bat to ask the user if they want a list of casinos before entering the casino name and username, then, if they select l (lower-case letter EL) for list, it produces the list of casinos. Currently getting 'error converting exit value'. Can anyone tell me the code for this?

@echo off
osql -STEMP7 -E -dAAMS888 -w256 -qEXIT("SET NOCOUNT ON SELECT casino_desc from casino") -b

set /p var1= Enter Casino Name : 
set /p var2= Enter Screen name : 

osql -STEMP7 -E -dAAMS888 -w256 -QEXIT("DECLARE @r int EXEC @r = usp_AddToObservationtbl '%var1%','%var2%' SELECT @r") -b -oc:\bat\observation.log
exit errorlevel

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

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

发布评论

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

评论(1

纵性 2024-11-26 23:21:26

通过将该行更改

exit errorlevel

exit %errorlevel%

You Want to return the value of the ERRORLEVEL 变量来修复退出值转换错误,因此您需要将名称括在 %s 中。

至于您的第一个问题,关于要求用户确认是否要显示赌场列表,您可以尝试对原始脚本进行类似的修改(添加的行以粗体突出显示):

@ECHO OFF

SET /P "NeedsList= Do you want to display the list? "

IF /I NOT [%NeedsList%] == [L] GOTO :cont
osql -STEMP7 -E -dAAMS888 -w256 -qEXIT("SET NOCOUNT ON SELECT casino_desc from casino") -b

:cont
set /p var1= Enter Casino Name : 
set /p var2= Enter Screen name : 

osql -STEMP7 -E -dAAMS888 -w256 -QEXIT("DECLARE @r int EXEC @r = usp_AddToObservationtbl '%var1%','%var2%' SELECT @r") -b -oc:\bat\observation.log
exit %errorlevel%

The exit value converting error is fixed by changing the line

exit errorlevel

to

exit %errorlevel%

You want to return the value of the ERRORLEVEL variable, so you need to enclose the name in %s.

As for you first question, about asking the user to confirm whether they want to display the list of casinos, you could try something like this modification of your original script (added lines are highlighted in bold):

@ECHO OFF

SET /P "NeedsList= Do you want to display the list? "

IF /I NOT [%NeedsList%] == [L] GOTO :cont
osql -STEMP7 -E -dAAMS888 -w256 -qEXIT("SET NOCOUNT ON SELECT casino_desc from casino") -b

:cont
set /p var1= Enter Casino Name : 
set /p var2= Enter Screen name : 

osql -STEMP7 -E -dAAMS888 -w256 -QEXIT("DECLARE @r int EXEC @r = usp_AddToObservationtbl '%var1%','%var2%' SELECT @r") -b -oc:\bat\observation.log
exit %errorlevel%
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文