open random file batch

Microsoft Windows xp professional w/serv...
July 11, 2010 at 00:02:17
Specs: Windows XP
hi,
I wonder how can i open one .bat(out of ten) document randomly each time when i start the computer.
ps: these ten documents are all in one file

thanks


See More: open random file batch

Report •

#1
July 11, 2010 at 08:02:12
ps: these ten documents are all in one file

Did you mean folder? Try the following:

@echo off

setlocal EnableDelayedExpansion

set BatFolder=c:\TenBats

set n=0
set /a rand=%random:~-1%+1
for %%f in ("%BatFolder%\*.bat") do (
  set /a n+=1
  if !n! equ %rand% (
    call "%%f"
    goto :eof
  )
)



Report •

#2
July 12, 2010 at 15:03:28
If your BAYs are cleverly named 1 through 10:

=========================

@echo off & setLocal EnableDELAYedeXpansion

set /a N=!RANDOM!%%10+1 & !N!


=====================================
Helping others achieve escape felicity

M2


Report •
Related Solutions


Ask Question