randomly select echo message from list

J

Jack

yah. I need to randomly select a message to print on the users screen.
I dont care if it selects from a list in the batch file or from a list
in a txt file. doesn't matter. any help, appreciated!
 
R

Ritchie

Jack said:
yah. I need to randomly select a message to print on the users screen.

@echo off & setlocal ENABLEEXTENSIONS

::List of messages
:;message one
:;message two
:;message three
:;message four

set "i=0" & for /f "delims==" %%a in ('set msg 2^>nul') do set "%%a="
for /f "delims=" %%a in ('findstr /b /c:":;" "%~f0"') do (
call set "msg%%i%%=%%a" & set /a i+=1
)

set /a x=(%random%%%i)
call set msg=%%msg%x%:~2%%
echo/%msg%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top