Trying to play a wav file with wmplayer.exe using Shell()

  • Thread starter Thread starter felecha
  • Start date Start date
F

felecha

I can get Windows Media Player to start, and play a wav file just fine
using a command line

"C:\Program Files\Windows Media Player\wmplayer.exe" c:\Temp\temp.wav

But I want it to come up from a VB.Net application, so the user will
select the recording he wants and click a button and code will call

Shell("C:\Program Files\Windows Media Player\wmplayer.exe
c:\Temp\temp.wav")

When called from my app, the wav file plays, but the Media Player
window won't come up. From a DOS prompt command line the WMP window
comes up and then plays the file.

I want the users to have the WMP window, not just hear the file.

I looked on MSDN and found a list of command line options, but nothing
in their list does any different.

Any clues?
 
felecha,

Just as your surrounding the path with spaces in it with " " quotes you also
must do this with shell.

Shell(""" & "C:\Program Files\Windows Media Player\wmplayer.exe" & """ &
"c:\Temp\temp.wav")


felecha said:
I can get Windows Media Player to start, and play a wav file just fine
using a command line

"C:\Program Files\Windows Media Player\wmplayer.exe" c:\Temp\temp.wav

But I want it to come up from a VB.Net application, so the user will
select the recording he wants and click a button and code will call

Shell("C:\Program Files\Windows Media Player\wmplayer.exe
c:\Temp\temp.wav")

When called from my app, the wav file plays, but the Media Player
window won't come up. From a DOS prompt command line the WMP window
comes up and then plays the file.

I want the users to have the WMP window, not just hear the file.

I looked on MSDN and found a list of command line options, but nothing
in their list does any different.

Any clues?
 
Well, this is veryinteresting.

I didn't mention in my post that I had tried it both ways already,
with the same result. That is, enclosing the path with the spaces in
it inside quotes (and using "" in VB.Net where I had " in DOS), and
then without.

That was at work. I have Windows XP Pro there. Here I am at home,
with the identical VisualStudio.Net installation, from the very same
Microsoft developer's kit DVD, but I run Windows 2000 Pro at home.

And now I find that both with and without the enclosing quotes, my
VB.Net code DOES bring up the WMP window on the screen and starts
playing the file.

So ... this is a difference in how XP and 2K handle the command from
my app?

I can't see till Iget back to work as to what WMP version is there,
but here I have 9.00.00.3075. The machine at work is an almost new
Dell 8300, with XP right out of the box. I suspect it's also version
9.
 
Someone just suggested that maybe the issue is a setting in Windows
somewhere, or in WMP, like where you choose an Option "Open WMP
window when called from a VB.Net application."

Any clues?
 
Back
Top