Problem with Process.StartInfo.Arguments line.

D

Dave M.

Hello,

I'm launching Windows Media Player successfully with the following code:


Dim myProcess As New Process

myProcess.StartInfo.FileName = "wmplayer.exe"

myProcess.StartInfo.Arguments = "\media\TestVideo.wmv /fullscreen"


This only works because I made a folder 'media' and the foldername contains
no spaces. Pointing to a file in a folder that has a space in the folder
name (such as \My Documents\ or \Storage Card\ fails, even though I
successfully check for the existance to the file before launching WMP. I'm
guessing the issue is with the way the myProcess.StartInfo.Arguments line is
parsed.

Does anyone have any ideas?

Thanks in advance for any help.

Dave M.
 
G

Guest

Try adding quotes to your command line so WMP knows where the filename
starts and ends, just as you would form a console.

myProcess.StartInfo.Arguments = "\"\My Folder\TestVideo.wmv\" /fullscreen"
 
D

dave m

Chris,

I appreciate the reply, but I'm still having problems! I initally had tried
nesting the quotes as you had suggested, but VS doesn't seem to like it in
this case. I generates a 'End of statement expected' error.

Dave M.
 
G

Guest

Then try a single quote. Or try starting WMP from teh command prompt and
whatever you enter there is what it expects here. The problem is that WMP
doesn't understand what you're passing into it.
 
P

Peter Foot [MVP]

You need to add quotes around the path, in VB this should be something
like:-
myProcess.StartInfo.Arguments = """\My Documents\TestVideo.wmv""
/fullscreen"

Peter
 
D

dave m

Thanks Peter! That fixed me up!!

Peter Foot said:
You need to add quotes around the path, in VB this should be something
like:-
myProcess.StartInfo.Arguments = """\My Documents\TestVideo.wmv""
/fullscreen"

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top