mardi 21 février 2017

How to make if statements in bat

I found some instructions to eject the disc drive on the Internet and I would like to know how to add a condition like typing a command to open it by means of an if statement. Here it is the code, for the moment I just repeat an infinite loop waiting 10 seconds in each iteration.

@echo off
:open
echo Set oWMP = CreateObject("WMPlayer.OCX.7")  >> %temp%\temp.vbs
echo Set colCDROMs = oWMP.cdromCollection       >> %temp%\temp.vbs
echo For i = 0 to colCDROMs.Count-1             >> %temp%\temp.vbs
echo colCDROMs.Item(i).Eject                    >> %temp%\temp.vbs
echo next                                       >> %temp%\temp.vbs
echo oWMP.close                                 >> %temp%\temp.vbs
%temp%\temp.vbs
timeout /t 1
del %temp%\temp.vbs
timeout /t 10
goto open
exit

Aucun commentaire:

Enregistrer un commentaire