Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript 将VBS脚本和mp3/其他扩展组合到可执行文件中_Vbscript_Mp3_Exe - Fatal编程技术网

Vbscript 将VBS脚本和mp3/其他扩展组合到可执行文件中

Vbscript 将VBS脚本和mp3/其他扩展组合到可执行文件中,vbscript,mp3,exe,Vbscript,Mp3,Exe,我想将VBS脚本文件与mp3音频文件结合起来 我的意思是,我希望脚本在后台自动播放mp3音频,并同时运行脚本 另一方面,我考虑用另一种语言编写脚本我不知道这个VBScript是否能让你知道如何从URL< /P>播放音乐。 Option Explicit Dim URL_Music URL_Music = "http://www.chocradios.ch/djbuzzradio_windows.mp3.asx" Call Play(URL_Music) '********************

我想将VBS脚本文件与mp3音频文件结合起来

我的意思是,我希望脚本在后台自动播放mp3音频,并同时运行脚本


<>另一方面,我考虑用另一种语言编写脚本

我不知道这个VBScript是否能让你知道如何从URL< /P>播放音乐。
Option Explicit
Dim URL_Music
URL_Music = "http://www.chocradios.ch/djbuzzradio_windows.mp3.asx"
Call Play(URL_Music)
'*************************************************
Sub Play(URL)
Dim Sound
Set Sound = CreateObject("WMPlayer.OCX")               
Sound.URL = URL
Sound.settings.volume = 100                               
Sound.Controls.play                                     
do while Sound.currentmedia.duration = 0                
    wscript.sleep 100                                       
loop                                                    
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000 
End Sub
'*************************************************
我想让脚本自动播放mp3音频中的 后台,并同时运行脚本

您可以尝试一下我为您制作的这个新vbscript,以便在脚本运行另一个任务时在后台播放音乐,直到结束,音乐也将停止

'**********************************Description in English***********************************
'This vbscript is created by Hackoo on 29/09/2019
'Sometimes some tasks can be taken a lot of time to end up.
'This code is created in order to play music in background while the script is running another
'task until to finish up and the music will stop too.
'So, the user can listen to the music playing while the script is running another task.
'**********************************Description en Français**********************************
'Parfois, certaines tâches peuvent prendre beaucoup de temps pour finir.
'Ceci est créé afin de jouer de la musique en arrière-plan pendant que,
'le script exécute une autre tâche jusqu’à la terminer et la musique s’arrêtera aussi.
'Ainsi, l'utilisateur peut écouter la musique pendant que le script exécute une autre tâche.
'*******************************************************************************************
Option Explicit
If AppPrevInstance() Then 
    MsgBox "The script is already Running" & vbCrlf &_
    CommandLineLike(WScript.ScriptName),VbExclamation,"The script is already Running"    
    WScript.Quit  
Else
    Call Run_as_Admin()
    Dim Title,EndUP,WS,fso,Temp,WSF_File,URL_Music,CMD,Process_Music,StartTime,Duration
    Title = "Playing music while another task is running by "& Chr(169) &" Hackoo 2019"
    EndUP = False
    Set WS = CreateObject("wscript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Temp = WS.ExpandEnvironmentStrings("%Temp%")
    WSF_File = Temp & "\Music.wsf"
    URL_Music = Random_Music
    Call Create_WSF_Music_File()
    CMD = "wscript.exe " & DblQuote(WSF_File) & " //job:PlayMusic "& DblQuote(URL_Music) &""
    Set Process_Music = WS.Exec(cmd)

    WS.Popup "Playing this Radio music "& DblQuote(URL_Music) & vbCrlf &_
    "in the background while the script is running another task until to finish it"_
    ,5,Title,vbInformation + vbSystemModal

    Do While Process_Music.Status = 0
        If EndUP = False Then
'**********************************************************************************************************************
'Your Main Code goes Here
StartTime = Timer
Call RUN_CMD ( _
            "echo.>%Tmp%\LogCMD.txt" &_
            "& (Tracert.exe www.codereview.stackexchange.com" &_
            "& Ping www.codereview.stackexchange.com" &_
            "& Tracert.exe www.google.com" &_
            "& Ping www.google.com" &_
            "& NetStat -abnof)>>%Tmp%\LogCMD.txt" &_
            "& Start /MAX %Tmp%\LogCMD.txt"_
            )

            Duration = FormatNumber(Timer - StartTime, 0)
            WS.Popup "The task had taken a run time until its completion about :" & vbCrlf &_
            vbTab & convertTime(Duration) & vbCrlf & _
            vbTab & WScript.ScriptName,10,Title,vbExclamation + vbSystemModal
'**********************************************************************************************************************
        Else
            On Error Resume Next  'to ignore "invalid window handle" errors
            Process_Music.Terminate
            On Error Goto 0
            EndUP = True
        End If
    Loop
End If
'----------------------------------------------------------------------------------------
Sub Create_WSF_Music_File()
    Dim oWSF
    Set oWSF = fso.OpenTextFile(WSF_File,2,True)
    oWSF.WriteLine "<job id=""PlayMusic"">"
    oWSF.WriteLine  "<script language=""Vbscript"">"
    oWSF.WriteLine  "Dim URL_Music"
    oWSF.WriteLine  "URL_Music = WScript.Arguments(0)"
    oWSF.WriteLine  "Call Play(URL_Music)"
    oWSF.WriteLine "Function Play(URL)"
    oWSF.WriteLine  "Dim Sound"
    oWSF.WriteLine  "Set Sound = CreateObject(""WMPlayer.OCX"")"               
    oWSF.WriteLine  "Sound.URL = URL"
    oWSF.WriteLine  "Sound.settings.volume = 100"                               
    oWSF.WriteLine  "Sound.Controls.play"                                     
    oWSF.WriteLine  "Do while Sound.currentmedia.duration = 0"                
    oWSF.WriteLine      "wscript.sleep 100"                                       
    oWSF.WriteLine  "Loop"  
    oWSF.WriteLine "End Function"
    oWSF.WriteLine  "</script>"
    oWSF.WriteLine "</job>"
End Sub
'----------------------------------------------------------------------------------------
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'----------------------------------------------------------------------------------------
Function RUN_CMD(StrCmd)
    Dim ws,MyCmd,Result
    Set ws = CreateObject("wscript.Shell") 
    MyCmd = "CMD /C " & StrCmd & " "
    Result = ws.run(MyCmd,0,True)
    EndUP = True
End Function
'----------------------------------------------------------------------------------------
Function Random_Music()
    Dim URL1,URL2,URL3,URL4,URL5,URL6,ListMusic,i,j,tmp
    URL1 = "http://94.23.221.158:9197/stream"
    URL2 = "http://www.chocradios.ch/djbuzzradio_windows.mp3.asx"
    URL3 = "http://vr-live-mp3-128.scdn.arkena.com/virginradio.mp3"
    URL4 = "http://185.52.127.168/fr/30201/mp3_128.mp3?origine=fluxradios"
    URL5 = "http://icecast.skyrock.net/s/natio_mp3_128k"
    URL6 = "http://185.52.127.173/fr/30601/mp3_128.mp3?origine=tunein"
    ListMusic = array(URL1,URL2,URL3,URL4,URL5,URL6)
    Randomize
    For i = 0 To UBound(ListMusic)
        j = Int((UBound(ListMusic) - i + 1) * Rnd + i)
        tmp = ListMusic(i)
        ListMusic(i) = ListMusic(j)
        ListMusic(j) = tmp
    Next  
    Random_Music=tmp
End Function
'----------------------------------------------------------------------------------------
Function AppPrevInstance()
    With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")  
        With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
            " AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")
            AppPrevInstance = (.Count > 1)
        End With
    End With
End Function    
'----------------------------------------------------------------------------------------
Function CommandLineLike(ProcessPath)
    ProcessPath = Replace(ProcessPath, "\", "\\")
    CommandLineLike = "'%" & ProcessPath & "%'" 
End Function
'----------------------------------------------------------------------------------------
Function convertTime(seconds)
    Dim ConvSec,ConvHour,ConvMin
   ConvSec = seconds Mod 60
   If Len(ConvSec) = 1 Then
         ConvSec = "0" & ConvSec
   End If
   ConvMin = (seconds Mod 3600) \ 60
   If Len(ConvMin) = 1 Then
         ConvMin = "0" & ConvMin
   End If
   ConvHour =  seconds \ 3600
   If Len(ConvHour) = 1 Then
         ConvHour = "0" & ConvHour
   End If
   convertTime = ConvHour & ":" & ConvMin & ":" & ConvSec
End Function
'----------------------------------------------------------------------------------------
Sub 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
End Sub
'----------------------------------------------------------------------------------------
”************************************************英文描述***********************************
'此vbscript由Hackoo于2019年9月29日创建
“有时候,有些任务可能要花很多时间才能完成。
'创建此代码是为了在脚本运行另一个脚本时在后台播放音乐
“任务完成后,音乐也会停止。
'因此,用户可以在脚本运行另一个任务时收听播放的音乐。
“*******************************************法语描述**********************************
“帕尔福利斯,一定要在最后时刻喝上一杯。
“这是一个计划中的音乐日,
“我的手稿很可爱,但我的手稿很漂亮,我的手稿很漂亮。”。
Ainsi,l'Usitateur peutécouter la musique pendent que le script exeécute une autre téche。
'*******************************************************************************************
选项显式
如果是AppPrevInstance(),则
MsgBox“脚本已在运行”&vbCrlf&_
CommandLineLike(WScript.ScriptName),VBEquipment,“脚本已在运行”
WScript.Quit
其他的
调用Run_作为_Admin()
Dim Title、EndUP、WS、fso、Temp、WSF_文件、URL_音乐、CMD、Process_音乐、开始时间、持续时间
Title=“在运行另一个任务时播放音乐”&Chr(169)和“Hackoo 2019”
结束=错误
设置WS=CreateObject(“wscript.Shell”)
设置fso=CreateObject(“Scripting.FileSystemObject”)
Temp=WS.ExpandEnvironmentStrings(“%Temp%”)
WSF_File=Temp&“\Music.WSF”
URL\u Music=随机音乐
调用Create_WSF_Music_File()
CMD=“wscript.exe”&DblQuote(WSF_文件)&”//job:PlayMusic“&DblQuote(URL_音乐)&”
设置进程\u Music=WS.Exec(cmd)
WS.Popup“播放此广播音乐”&DblQuote(URL_音乐)&vbCrlf&_
“在后台,脚本正在运行另一个任务,直到完成它”_
,5,标题,vbInformation+vbSystemModal
处理音乐时执行。状态=0
如果EndUP=False,则
'**********************************************************************************************************************
“你的主代码在这里
开始时间=计时器
调用RUN_CMD(_
“echo.>%Tmp%\LogCMD.txt”&_
“&(Tracert.exe www.codereview.stackexchange.com”&_
“&Ping www.codereview.stackexchange.com”&_
“&Tracert.exe www.google.com”&_
“&Ping www.google.com”&_
“&NetStat-abnof)>>%Tmp%\LogCMD.txt”&_
“&Start/MAX%Tmp%\LogCMD.txt”_
)
持续时间=格式编号(计时器-开始时间,0)
WS.Popup“任务在完成之前的运行时间大约为:”&vbCrlf&_
vbTab和convertTime(持续时间)以及vbCrlf和_
vbTab&WScript.ScriptName,10,Title,vb惊叹号+vbSystemModal
'**********************************************************************************************************************
其他的
在错误恢复下一步“忽略无效窗口句柄”错误
处理音乐
错误转到0
结束=真
如果结束
环
如果结束
'----------------------------------------------------------------------------------------
子创建音乐文件()
昏暗的天气
设置oWSF=fso.OpenTextFile(WSF_文件,2,True)
oWSF.WriteLine“”
oWSF.WriteLine“”
oWSF.WriteLine“昏暗的音乐”
oWSF.WriteLine“URL\u Music=WScript.Arguments(0)”
oWSF.WriteLine“呼叫播放(URL_音乐)”
oWSF.WriteLine“函数播放(URL)”
oWSF.WriteLine“昏暗的声音”
oWSF.WriteLine“Set Sound=CreateObject(““WMPlayer.OCX”)”
oWSF.WriteLine“Sound.URL=URL”
oWSF.WriteLine“Sound.settings.volume=100”
oWSF.WriteLine“声音、控制、播放”
oWSF.WriteLine“Do while Sound.currentmedia.duration=0”
oWSF.WriteLine“wscript.sleep 100”
oWSF.WriteLine“循环”
oWSF.WriteLine“结束函数”
oWSF.WriteLine“”
oWSF.WriteLine“”
端接头
'----------------------------------------------------------------------------------------
函数DblQuote(Str)
DblQuote=Chr(34)和Str&Chr(34)
端函数
'----------------------------------------------------------------------------------------
函数运行指令(StrCmd)
Dim ws、MyCmd、结果
设置ws=CreateObject(“wscript.Shell”)
MyCmd=“CMD/C”和StrCmd&“
结果=ws.run(MyCmd,0,True)
结束=真
端函数
'----------------------------------------------------------------------------------------
函数Random_Music()
Dim URL1、URL2、URL3、URL4、URL5、URL6、ListMusic、i、j、tmp
URL1=”http://94.23.221.158:9197/stream"
URL2=”http://www.chocradios.ch/djbuzzradio_windows.mp3.asx"
URL3=”http://vr-live-mp3-128.scdn.arkena.com/virginradio.mp3"
URL4=”http://185.52.127.168/fr/30201/mp3_128.mp3?origine=fluxradios"
URL5=”http://icecast.skyrock.net/s/natio_mp3_128k"
URL6=”http://185.52.127.173/fr/30601/mp3_128.mp3?origine=tunein"
ListMusic=数组(URL1、URL2、URL3、URL4、URL5、URL6)
随机化
法罗群岛