简体   繁体   中英

Opening a random file out of a selection with batch on startup

I'm trying to use a batch file to open another random batch file (out of 6 possible) on startup. This gives me a different moving background using VLC. The file names are LB0.bat, LB1.bat ... LB5.bat. What I have now does not work.

set /a num=%random% %%6

FOR %%num DO start /min C:\LivingBackground\LB%%num.bat

Without the random function, it works fine. Ie, to open LB0.bat, i can just use;

start /min C:\LivingBackground\LB0.bat

Remove the FOR %%num DO . Leave the rest of the line.

BUT

start /min "" C:\LivingBackground\LB%num%.bat

Note that batch variables are accessed by %var% ansd a syntax quirk makes the first quoted string in a start command the window title.

You're not using a string in your start command, so the ""` is optional.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM