samedi 16 février 2019

Echo adding a random value

I have a batch file that create another batch file.

I need to add inside the echo a random function to have numbers from 1 to 6.

I tried to add a command inside but the output of echo do not works.

My code:

echo :::: Start Of The Command Block ::::
echo/
echo PING -n 30 localhost ^>NUL 2^>^&1
echo PING -n 5 www.facebook.com^|FIND /I "TTL"^>NUL
echo IF NOT "%%ERRORLEVEL%%"=="1" ^(
echo rundll32 user32.dll,MessageBeep 0x00000010L
echo set /a num=%%random%% %%%%6 +1
echo start "" "D:\Program Files\Firefox Portable %%num%%\FirefoxPortable.exe"
echo TIMEOUT /T 60 /NOBREAK ^>NUL
echo goto search
echo ^)
echo :search

I added this to obtain a random number from 1 to 6

   echo set /a num=%%random%% %%%%6 +1
   echo start "" "D:\Program Files\Firefox Portable %%num%%\FirefoxPortable.exe"

in output of echo i do not look any number.

I aspect a path like

"D:\Program Files\Firefox Portable 2\FirefoxPortable.exe"

or

"D:\Program Files\Firefox Portable 5\FirefoxPortable.exe"

But my code return an output like

"D:\Program Files\Firefox Portable \FirefoxPortable.exe"

Any suggestion please?

Aucun commentaire:

Enregistrer un commentaire