Etape 2: Type dans le code
Dim myDateString
Dim thing1
thing1 = 0
myDateString = Date()
Si myDateString < "04/02/10" puis
thing1 = 1
fin si
Si thing1 = 1 then
Si myDateString > « 31/04/10 » puis
thing1 = 2
fin si
fin si
Si thing1 = 2 then
faire
Set oWMP = CreateObject ("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
Si colCDROMs.Count > = 1 then
Pour i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i). EJECT
Next ' cdrom
End If
boucle
D’autre
WScript.Quit 1
End If
Maintenant, je vais vous expliquer que :
Dim myDateString
Dim thing1
Ceci définit deux variables que nous pouvons utiliser ultérieurement dans le code.
thing1 = 0
myDateString = Date()
Cela définit les variables. thing1 est une valeur numérique, mais myDateString contient la date à laquelle il s’exécute.
Si myDateString < "04/02/10" puis
thing1 = 1
fin si
Si thing1 = 1 then
Si myDateString > « 31/04/10 » puis
thing1 = 2
Il détecte si c’est poisson d’avril ou pas et définit en conséquence thing1.
Si thing1 = 2 then
faire
Set oWMP = CreateObject ("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
Si colCDROMs.Count > = 1 then
Pour i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i). EJECT
Next ' cdrom
End If
boucle
Cela ne fait l’ouverture et la fermeture. ELLE appelle une fonction de joueur de médias de windows pour ouvrir le lecteur, puis il répète.
D’autre
WScript.Quit 1
C’est exécutée si elle n’est pas poisson d’avril, puis ferme le fichier.