2013-03-20 8 views

답변

1

예. 여기에 개념 증명이 있습니다.

@echo off 
setlocal enabledelayedexpansion 

set string[0]=This is the first random line. 
set string[1]=This is the second random line. 
set string[2]=This is the third random line. 

set /a idx=%random% * 3/32768 

echo !string[%idx%]! 

다음은 Windows 배치 스크립트에서 generating random numbers에 대한 추가 정보를 원하시면입니다.

+0

고마워요! 그것이 나를 허용 할 때이 허용 된 대답을 할 것입니다! :) –

0
@echo OFF 
SETLOCAL 
SET message0=message zero 
SET message1=message one 
SET message2=message two 
SET message3=message three 
SET message4=message four 

:: running 10 times 

FOR /l %%i IN (1,1,10) DO CALL :showme 
GOTO :eof 

:showme 
SET /a select=%RANDOM% %% 5 
CALL SET message=%%message%select%%% 
ECHO %message% 
GOTO :eof 
관련 문제