0

I am new to all of this, it took me some hours to make the following:

@ECHO OFF
CLS
ECHO===========================================================================
ECHO                                    MENU
ECHO===========================================================================
ECHO...........................................................................
ECHO                        Type 1,2 or 3 then press ENTER:
ECHO...........................................................................
ECHO.
ECHO 1 - SERVER XXX.XXX.XXX.1
ECHO 2 - SERVER XXX.XXX.XXX.2
ECHO 3 - EXIT
ECHO.

SET /P OPT=Type 1,2 or 3 then press ENTER:
IF %OPT%==1 GOTO MSTSC 1
IF %OPT%==2 GOTO MSTSC 2
IF %OPT%==3 GOTO EOF

:MSTSC 1
mstsc.exe /v:XXX.XXX.XXX.1 /admin /F
GOTO EOF

:MSTSC 2
mstsc.exe /v:XXX.XXX.XXX.2 /admin /F
GOTO EOF

:EOF
EXIT

When I select options 1 and 3 they work fine, when I select option 2 I get the same result as option 1. It's not connecting the second server, how can this be fixed? Also how can I have the command prompt close as soon as the command is executed? The command prompt closes only after I close MSTSC.

Thank you all.

Also since this is my first attempt at a batch file please tell me of all the mistakes so I can learn.

4

1 回答 1

2

标签名称中不能有空格。第一个案例“偶然”起作用。例如,使用MSTSC_1MSTSC_2作为标签。

于 2013-07-21T14:21:40.243 回答