Process.Start

G

Guest

The command below opens a Word document but to use it I need to know the path
for Winword.EXE

Process.Start(C:\Office2003\OFFICE11\WINWORD.EXE, C:\Data\Print.rtf")

Is there a command that I can use to open it without knowing the path by
using the Information that Windows has for Registered file types??

Alternately, is there a reliable way to get this path by reading it from the
Registry? I prefer not doing a directory search.
 
C

Carlos J. Quintero [.NET MVP]

You can use directly Process.Start("C:\Data\Print.rtf") and the file will
be open with the app which registered the .rtf type.

If you want to use explictly Word, the best approach is to use automation to
launch it and open the document.

The most fragile approach is to read a registry entry such as
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Word\InstallRoot to get
the path to winword.exe. Notice that I used 11.0, while a user can have a
lower version.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
H

Herfried K. Wagner [MVP]

genojoe said:
Process.Start(C:\Office2003\OFFICE11\WINWORD.EXE, C:\Data\Print.rtf")

Is there a command that I can use to open it without knowing the path by
using the Information that Windows has for Registered file types??

At least on my machines, it was always possible to call "winword.exe"
without specifying its path.
 

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