Play media file via vbscript?  
Author Message
AndrewWiseman





PostPosted: Sat Jan 15 11:23:15 CST 2005 Top

VB Scripts >> Play media file via vbscript?

play sound file only,no GUI needed,

Visual Studio1  
 
 
Torgeir





PostPosted: Sat Jan 15 11:23:15 CST 2005 Top

VB Scripts >> Play media file via vbscript?

> play sound file only,no GUI needed,
>
Hi

Set oShell = CreateObject("Wscript.Shell")
sWaveFile = "%windir%\media\tada.wav"
oShell.Run "sndrec32.exe /embedding /play /close """ _
& sWaveFile & """", 0, True


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 
 
news





PostPosted: Sat Jan 15 19:00:42 CST 2005 Top

VB Scripts >> Play media file via vbscript? But...It support WAV format only,Can I use it to play mp3 or wma file?



>
> > play sound file only,no GUI needed,
> >
> Hi
>
> Set oShell = CreateObject("Wscript.Shell")
> sWaveFile = "%windir%\media\tada.wav"
> oShell.Run "sndrec32.exe /embedding /play /close """ _
> & sWaveFile & """", 0, True
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx


 
 
Miyahn





PostPosted: Sun Jan 16 01:31:48 CST 2005 Top

VB Scripts >> Play media file via vbscript?
> But...It support WAV format only,Can I use it to play mp3 or wma file?

How about this?
(Only tested on WindowsXP Home Japanese version.)

Const Prog = """C:\Program Files\Windows Media Player\wmplayer"" "
Const Sound = """C:\Documents and Settings\All Users\Documents\My Music\music.wma"""
Dim QStr, I, cProc, Proc
CreateObject("Wscript.Shell").Run Prog & Sound, 0
With GetObject("winmgmts:\root\cimv2")
QStr = "Select * from " & _
"Win32_PerfFormattedData_PerfProc_Process Where name='wmplayer'"
Set cProc = .ExecQuery(QStr)
For Each Proc in cProc
Do While I < 2
Proc.Refresh_: WScript.Sleep 1000
If Proc.PercentProcessorTime = 0 Then I = I + 1 Else I = 0
Loop
Next
QStr = "Select * from Win32_Process Where Name = 'wmplayer.exe'"
Set cProc = .ExecQuery (QStr)
For Each Proc in cProc: Proc.Terminate(): Next
End With
Set Proc = Nothing: Set cProc = Nothing

--
Miyahn (Masataka Miyashita) JPN
Microsoft MVP for Microsoft Office - Excel(Jan 2005 - Dec 2005)


 
 
news





PostPosted: Sun Jan 16 03:41:34 CST 2005 Top

VB Scripts >> Play media file via vbscript? It lasts only a few seconds and stops.


> But...It support WAV format only,Can I use it to play mp3 or wma file?



> >
> > > play sound file only,no GUI needed,
> > >
> > Hi
> >
> > Set oShell = CreateObject("Wscript.Shell")
> > sWaveFile = "%windir%\media\tada.wav"
> > oShell.Run "sndrec32.exe /embedding /play /close """ _
> > & sWaveFile & """", 0, True
> >
> >
> > --
> > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > Administration scripting examples and an ONLINE version of
> > the 1328 page Scripting Guide:
> > http://www.microsoft.com/technet/scriptcenter/default.mspx
>
>


 
 
Torgeir





PostPosted: Sun Jan 16 13:04:41 CST 2005 Top

VB Scripts >> Play media file via vbscript?

> But...It support WAV format only,Can I use it to play mp3
> or wma file?
Hi

No, but the script in the link below does.

Change oWMP.PlayCount from 0 to 1 to play the song only once, and
change oIE.Visible from True to False if you don't want a GUI.


http://groups.google.co.uk/groups?selm=uiUXwQtsEHA.2960%40TK2MSFTNGP10.phx.gbl



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx