Batch script – exempel

Koden skapar ett exempel på ett prov. Det finns några fel som hindrar copy-paste funktionen.

@echo off
:: Interacting with a user
echo ***********************************
echo Testing your knowledge about
echo Network Administration
echo ***********************************
echo.
pause
cls
color a
:: Switch to page one
one
echo.
echo 1.- Which of the following are required to create a domain controller successfully?
echo.
echo A) A valid DNS domain name
echo B) A FireWall server
echo C) A DHCP server to assign an IP address to the domain controller
echo D) A WINS server
echo.
set /p ch1=Enter your choice:
echo.
if not defined ch1 (goto one)
if %ch1%==A goto yes1
if %ch1%==B goto no1
if %ch1%==C goto no1
if %ch1%==D goto no1
:: Switch to page one if any character but not A B C D
echo.
echo Invalid choice, please try again!
echo Press any key to continue . . .
pause>nul
goto one
:: Switch to page no1 if B, C or D
no1
echo Sorry, That answer is incorrect. Try Again!
echo Press any key to continue . . .
echo.
pause>nul
goto one
:: Switch to page yes1 if the answer is A
yes1
echo.
echo You are correct! To create a domain requires a valid DNS domain name.
echo Press any key to continue . . .
echo.
pause>nul
goto two
:: Switch to pages two
two
echo.
echo 2.- Which of the following groups can shut down a domain controller?
echo.
echo A) Account Operators
echo B) Installators
echo C) Internet Operators
echo D) Print Operators
echo.
set /p ch2=Enter your choice:
echo.
if not defined ch2 (goto two)
if %ch2%==A goto no2
if %ch2%==B goto no2
if %ch2%==C goto no2
if %ch2%==D goto yes2
:: Switch to page two if any character but not A B C D
echo.
echo Invalid choice, please try again!
echo Press any key to continue . . .
pause>nul
goto two
:: Switch to page no2 if A, B or C
no2
echo Sorry, That answer is incorrect. Try Again!
echo Press any key to continue . . .
echo.
pause>nul
goto two
:: Switch to page yes2 if the answer is D
yes2
echo.
echo You are correct! Print Operators can shutdown a Domain Controller.
echo Server Operators and Backup Operators can also shutdown a DC.
echo.
echo Press any key to continue . . .
pause>nul
goto three
:: Switch to page three
three
echo.
echo 3.- You want to join a computer to the domain. Which command should you use?
echo.
echo A) dsadd
echo B) netdom
echo C) dsget
echo D) dsjoin
echo.
set /p ch3=Enter your choice:
echo.
if not defined ch2 (goto three)
if %ch3%==A goto no3
if %ch3%==B goto yes3
if %ch3%==C goto no3
if %ch3%==D goto no3
:: Switch to page three if any character but not A B C D
echo.
echo Invalid choice, please try again!
echo Press any key to continue . . .
pause>nul
goto three
:: Switch to page no3 if A, C or D
no3
echo Sorry, That answer is incorrect. Try Again!
echo.
echo Press any key to continue . . .
pause>nul
goto three
:: Switch to page yes3 if the answer is B
yes3
echo.
echo You are correct! netdom join can join computers to a domain.
echo.
echo Press any key to finish the test.
pause>nul