Batch: Random Number

Toshiba / Satellite m40
August 18, 2009 at 14:03:39
Specs: Linux Mint-xfce, 1.397 GHz / 958 MB
Hi, I program with batch files often. But i want to expand more. My goal is to create a hacking Simulation game in DOS. Not real, but i will try to simulate some kind of game.

Now, i don't want it being the same every time.
So i was wondering, Does anyone know if it's possible to create a random number or letter generator.

For instance. I want them to input something like "connect" then a website after (a fake website obviously) but i want the website to randomly generate so everytime you load up the batch.
Theres a different website to connect too, So it doesn't get boring with the same website.

Like this, You get a mission briefing. The brief is randomly selected from a group of different missions. It gives you a website to hack, But the website will be different everytime. And when the use is actually playing, he'll have to type the website the brief gave you.

Sorry if this is complicated.
Maybe this will help, Is it possible to generate a random website made up of random numbers and letters. Then automatically sets it as a variable ?
Thats kinda what i want.

I have another question which I'll ask in another post as i have to go now.

Need BatchFile Help ?
Msg me :)

See More: Batch: Random Number

Report •

August 18, 2009 at 14:25:20
in 2000 and up there is the %random% variable that returns a number 0-32767; for letters you could do something like this:

setlocal enabledelayedexpansion
set /0=a
set /1=b
set /2=c
set /3=d

set /a letter=%random% %% 26
echo !/%letter%!

Report •

August 18, 2009 at 14:44:51
@echo off
setlocal enabledelayedexpansion
for %%a in ("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o"
"p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") do (
set %%~a=!random!

variable !a! - !z! would be a number

There are no stupid questions, just stupid people.

Report •

August 18, 2009 at 15:43:16
Thanks for that guys!
I'm glad it's possible! lol!

Need BatchFile Help ?
Msg me :)

Report •

Related Solutions

August 18, 2009 at 16:20:24
%random% will generate a 5 number code

Report •

August 19, 2009 at 07:36:25

He says he's using linux and wants a bat for DOS.

Hard to see any of that working in either.

If at first you don't succeed, you're about average.


Report •

August 19, 2009 at 10:00:37
Well there's a story there. I used windows for too long and ended up changing to linux, Although my nans pc which i spend a lot of time on is Windows XP. and my laptop is now linux.

Also, i can run windows on linux with virtualOS
All i need is a WindowsXP ISO file lmfao. Gotta find one somewhere.

Need BatchFile Help ?
Msg me :)

Report •

Ask Question