Process.Start

wsyeager

Centurion
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
I'm trying to start an IE process so that the browser can launch the proper application after bringing the file into the browser in order to bring up the associated file.

code is as follows:

<code>

Process.Start("IExplore.exe", "C:\Temp\myFile.txt")

</code>

The file "C:\Temp\myFile.txt" exists on my local hard drive. It's a small text file.

No error occurs after the statement is executed. Another application doesn't for the file doesn't pop up at all.

How can I get the proper application to launch? What am I missing?
 
The process.start method is used to create multithreaded applications, not to execute files. The command you are looking for is Shell():

Shell("IExplore.exe C:\Temp\myFile.txt")

This should run internet explorer and throw the txt file in as an argument without any hassle.

Note that it wouldn't work properly on my own machine, as I have Windows XP x64 so that I have both a 32- and 64- bit iexplorer - VB can't figure out which one to launch, thus it gives a 404 error. I think it would be safer to specify the explorer's full path if possible.
 
If you just launch the file itself the default application should be opened anyway,
C#:
System.Diagnostics.Process.Start("c:\\boot.ini");
launches boot.ini in notepad as that is the default text editor on my system.

You can also invoke any registered application through it's context menu verb like so
C#:
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo("C:\\boot.ini");
si.Verb = "Print";
System.Diagnostics.Process.Start(si);

be aware that if you are running this on the server this will cause the application to be launched on the server not on the client's machine.
 
Last edited:
I tried using that, but am consistently getting a "system.io.filenotfound" execption even though when I take that path string and put it inside internet explorer, the file comes up. So, I am sure the file exists.

Is the Shell command strictly for Windows or can it work on the web. If it supposedly can work on the web, it won't work with what I'm doing.....
 
Is this running as part of an ASP.Net application? If so this code will execute on the server not the client pc.
If you are trying to get a client's browser to execute the above code then it cannot be done this way.

The Shell command is really just for compatability with VB6, Process.Start and the related classes are the prefered .Net way of doing things.
 
Back
Top