Option Explicit
'Run as Admin
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute DblQuote(WScript.FullName) _
, DblQuote(WScript.ScriptFullName) & " /elevate", "", "runas", 1
WScript.Quit
End If
Dim FilePath,TaskName,Repeat_Task,Sound
FilePath = WScript.ScriptFullName
TaskName = "PlayMusic"
Repeat_Task = 120 REM Pour répeter la tâche chaque 2 heures=120 min
Call Create_Schedule_Task(Repeat_Task,TaskName,FilePath)
Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "E:\hubiC\Sauvegarde\DownloadPrgBar\IbizaMix.mp3"
Sound.Controls.play
Do while Sound.currentmedia.duration = 0
wscript.sleep 100
Loop
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000
'----------------------------------------------------------------
REM Fonction pour ajouter des guillemets doubles dans une variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'-----------------------------------------------------------------
Sub Create_Schedule_Task(Repeat_Task,TaskName,FilePath)
Dim Ws,Task,Result
Set Ws = CreateObject("WScript.Shell")
Task = "CMD /C Schtasks /Create /SC DAILY /ST 08:00 /F /RI "&_
Repeat_Task &" /DU 24:00 /TN "& TaskName &" /TR "& FilePath &""
Result = Ws.run(Task,0,True)
End Sub
'-----------------------------------------------------------------