Please forgive me re-posting this question since I wasn't clear in my
original post.
-------->
Starting an external process needs to pass it a ProcessStartInfo() object.
ProcessStartInfo has a property "UseShellExecute" that can open/print a
file. For example, here's a piece of code that launches an external process
to open a Microsoft Word Document:
Process p = new Process();
ProcessStartInfo s = new ProcessStartInfo();
s.Verb = "Print";
s.FileName = @"C:\twain.doc";
p.StartInfo = s;
p.StartInfo.UseShellExecute = true;
p.Start();
The code executes without a problem, openning the document with Microsoft
Word. However, I cannot grab any handle of the newly launched process.
Accessing p.Handle will throw an exception of "no associated process", and
in fact, most of the fields of p are either null or with the same exception.
If I try the same code above but with FileName either an EXE file or TXT
files, I can grab the new process handle without any problem. My guess is
the file extension association. Grabbing the handle of a launched process
from an executable file is obviously easy. Grabbing the handle of a "TXT"
file might be easy by just looking at the registry key "shell\open\command".
However, for Microsoft Word document, it uses something called "DDEEXEC"
server, maybe that's the reason Process.Start() does not return any handle?
I've been stuck on this for a while and what I need to do is to launch an
external application on files and be able to monitor the process of the
external application, if it hangs kill it and restart over again. My
alternatives include attempting to implement the mechanism of calling
DDEEXEC in my own code and thus to grab the handle (if not possible at all),
or just monitor all processes on the computer and detect the newly added
process (which is resource-consuming and inaccurate).
Please try the code I included above, any help or hint will be greatly
appreciated!
Regards,
- Fei - 1 3637
No problem here running Word8 (Office 2003) on XP.
HCLR\word.Document\shell\print\command\default should look like:
REG_SZ "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE" /x /n
/dde
command\command:
REG_MULTI_SZ "']gAVn-}f(ZXfeAR6.jiWORDFiles>P`os,1@SW=P7v6GPl]Xh /x /n
/dde"
Willy.
"Fei Yuan" <fe*@carmelvision.com> wrote in message
news:OH**************@TK2MSFTNGP14.phx.gbl... Please forgive me re-posting this question since I wasn't clear in my original post. -------->
Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a property "UseShellExecute" that can open/print a file. For example, here's a piece of code that launches an external process to open a Microsoft Word Document:
Process p = new Process(); ProcessStartInfo s = new ProcessStartInfo(); s.Verb = "Print"; s.FileName = @"C:\twain.doc"; p.StartInfo = s; p.StartInfo.UseShellExecute = true; p.Start();
The code executes without a problem, openning the document with Microsoft Word. However, I cannot grab any handle of the newly launched process. Accessing p.Handle will throw an exception of "no associated process", and in fact, most of the fields of p are either null or with the same exception.
If I try the same code above but with FileName either an EXE file or TXT files, I can grab the new process handle without any problem. My guess is the file extension association. Grabbing the handle of a launched process from an executable file is obviously easy. Grabbing the handle of a "TXT" file might be easy by just looking at the registry key "shell\open\command". However, for Microsoft Word document, it uses something called "DDEEXEC" server, maybe that's the reason Process.Start() does not return any handle?
I've been stuck on this for a while and what I need to do is to launch an external application on files and be able to monitor the process of the external application, if it hangs kill it and restart over again. My alternatives include attempting to implement the mechanism of calling DDEEXEC in my own code and thus to grab the handle (if not possible at all), or just monitor all processes on the computer and detect the newly added process (which is resource-consuming and inaccurate).
Please try the code I included above, any help or hint will be greatly appreciated!
Regards, - Fei - This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dave |
last post by:
Hi,
Does anyone know how I could make an .exe launched server
side from an aspx file run faster? When I use javascript
client side it of couse is much faster. Here's my code
This code does...
|
by: Fei Yuan |
last post by:
Starting an external process needs to pass it a ProcessStartInfo() object.
ProcessStartInfo has a property "UseShellExecute" that can open/print a
file. However, I'm having a hard time getting the...
|
by: Fei Yuan |
last post by:
Please forgive me re-posting this question since I wasn't clear in my
original post.
----
Starting an external process needs to pass it a ProcessStartInfo() object.
ProcessStartInfo has a...
|
by: James Li |
last post by:
I need to run multiple .bat files(in specific order, sychronously) from my C#
windows app. I also want to hide the DOS command window so that users don't
see them.
Basically my program lanches...
|
by: Sam Marrocco |
last post by:
I seem to be having a devil of a time killing a process....
If I launch an applicaton such as notepad.exe as a Process, I can kill
it with no problem. However, if I launch a particulare...
|
by: PokerJoker |
last post by:
I created a monitor program that checks for certain critera and then launches
other executables to perform maintenence tasks.
One of these executables uses a DLL, when launched by double...
|
by: Zorpiedoman |
last post by:
dim FileName as string = "Test.doc"
dim P as Process = Process.Start(FileName)
'--P is NOTHING even though document opens!!!
dim Q as new process
Q.StartInfo.FileName = FileName
P = Q.start...
|
by: Kerem Gümrükcü |
last post by:
Hi,
i wonder that the Process.Start(...) needs full path to the
executable to start it, even the executable is listed in the
PATH Variable and can be launched from any console
on my system. Is...
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |