"bvb47 via WinServerKB.com" <u37442@uwe> wrote in message
news:797b38778d19c@uwe...
> Hello!,
>
> I'm trying to obtain a random number in batch file.
>
> if I type
>> set /a X=%random%%108
> in command prompt work ok, but if I put this instruction in batch file,
> don't
> work!
>
> anybody know why?
>
> thanks!
>
> --
> Message posted via http://www.winserverkb.com
>
At a command prompt I get:
nnnnn%108
where nnnnn is a random integer. In a batch file I get:
nnnnnn08
This is because %1 is blank. If I pass "Test" to the batch file as the first
argument, I get an error because "Test" is not numeric. If I pass 23 as the
argument, I get:
nnnnnn2308
Seems to work for me. Of course the environment variable only lasts until I
exit the command prompt.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net
--