开发者

tidying up .BAT file

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. Current开发者_高级运维ly 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


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%
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜