|
Answer» Hi
I would like my Windows to startup with a different startup sound each time I log in but I have not written any batch file before. Please help me to get started.Change "C:\my wav FILES\" below to where you STORE your WAV files. Pick any startup wav sound and note the filename.
Change this part below "c:\location and name\of your\startup wav file.wav" to the location and name you picked.
At the moment it will only echo the copy command and then pause, so you can test it. Remove the echo keyword and the pause keyword when you are SURE it is echoing random names, to make it function, and put it in your startup group.
The random file routine came from Dostips.
Code: [Select]@echo off
cd /d "C:\my wav files\"
set "$=" for %%a in (*.wav) do set /a $+=1 & for /f %%b in ('call echo.%%$%%')do set "$file[%%b]=%%a" set /a $random=%random% %% $ + 1
call set "file=%%$file[%$random%]%%" echo copy /b /y "%file%" "c:\location and name\of your\startup wav file.wav" pause The scipt is not working. My waves files are located at C:\Media.
My files in C:\Media: Sound1.wav Sound2.wav
Below is my modification. I save this batch file at Startup folder . The file name keep changinga at the 2nd last STATEMENT echo copy /b /y "%file%" "c:\Media\Sound1.wav
everytime it plays the same file after restarts. Please help.
@echo off
cd /d "C:\Media"
set "$=" for %%a in (*.wav) do set /a $+=1 & for /f %%b in ('call echo.%%$%%')do set "$file[%%b]=%%a" set /a $random=%random% %% $ + 1
call set "file=%%$file[%$random%]%%" echo copy /b /y "%file%" "c:\Media\Sound1.wav" pauseQuote from: Learning81 on November 06, 2012, 11:57:13 PM The scipt is not working. My waves files are located at C:\Media. The file name keep changinga at the 2nd last statement echo copy /b /y "%file%" "c:\Media\Sound1.wav
Change it to this line, now that it is echoing the random files.
copy /b /y "%file%" "c:\Media\Sound1.wav" >nul
and remove the pause
|