Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2007

Tip: Looking for answers? Try searching our database.

About System.Process of .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benny Lam - 18 Dec 2007 01:26 GMT
Hi,

I have a question about System.Process of .NET in C#...

in this code:

       static void Main(string[] args)
       {
           string filename = args[0];

           Process p = new Process();
           p.StartInfo.FileName =filename;
           p.StartInfo.UseShellExecute = true;
           p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
           p.Start();
           p.WaitForExit();
           Console.WriteLine("Bye");
       }

When i use it to open file, e.g. test.exe c:\123.xls and text.exe c:\456.xls.

the second text.exe will show the error.

that means Process can not monitor the same application at the same time.
Right?

Anyone knows how to solve it?
Phil Wilson - 18 Dec 2007 19:01 GMT
You'll need to be more explicit. What is this error that you're referring
to?
Signature

Phil Wilson
[MVP Windows Installer]

> Hi,
>
[quoted text clipped - 24 lines]
>
> Anyone knows how to solve it?
Benny Lam - 19 Dec 2007 02:33 GMT
Hi Wilson,

It shows the p.WaitForExit has error, "No process is associated with this
object."

I'm doing the test during two "cmd.exe"...

> You'll need to be more explicit. What is this error that you're referring
> to?
[quoted text clipped - 26 lines]
> >
> > Anyone knows how to solve it?
Family Tree Mike - 19 Dec 2007 02:43 GMT
> Hi Wilson,
>
[quoted text clipped - 5 lines]
> > You'll need to be more explicit. What is this error that you're referring
> > to?

Are you seeing both spreadsheets shown in one instance of Excel?  That is
what I would expect.
Benny Lam - 19 Dec 2007 12:22 GMT
yes, i think so.

But it's not using different thread to monitor it? Because I think it should
be monitoring per session.

um... anything i can solve it?

> > Hi Wilson,
> >
[quoted text clipped - 8 lines]
> Are you seeing both spreadsheets shown in one instance of Excel?  That is
> what I would expect.
Family Tree Mike - 19 Dec 2007 12:30 GMT
If you are really after working with MS office objects, then I would use
office interop objects rather than processes.  By connecting to an
Excel.Application object, you should be able to monitor when each sheet is
closed, edited, printed, or anything else.  With a singleton application,
like Excel, I'm afraid you cannot get to what I believe you are seeking.

In general though, your code would have worked.  Take notepad for example.  
It would have opened two instances of itself, each with the provided file.

> yes, i think so.
>
[quoted text clipped - 15 lines]
> > Are you seeing both spreadsheets shown in one instance of Excel?  That is
> > what I would expect.
Benny Lam - 19 Dec 2007 14:59 GMT
Sigh.... I may need to deeply consider your suggestion... Many thanks!

But, i still want to hear other comments...

> If you are really after working with MS office objects, then I would use
> office interop objects rather than processes.  By connecting to an
[quoted text clipped - 24 lines]
> > > Are you seeing both spreadsheets shown in one instance of Excel?  That is
> > > what I would expect.
Patrice - 19 Dec 2007 18:25 GMT
I noticed you taked about cmd.exe ? What if you launch the real exe file
instead ?

If you are using something like start or cmd myfile.ext, I'm afraid it will
launch the application associated with the "ext" extension and then will
terminate. So basically you are not monitoring the actual application but
the application that launches the actual application...

I would do a quick test using notepad.exe as suggested by Mike as a proof of
concept (to see if it works when launching notepad.exe and to see if it
still works if using cmd.exe to open a text file that is launching
notepad.exe indirectly still works or make what previously worked fails)...

--
Patrice

> Sigh.... I may need to deeply consider your suggestion... Many thanks!
>
[quoted text clipped - 35 lines]
>> > > That is
>> > > what I would expect.
Benny Lam - 21 Dec 2007 15:42 GMT
Oh... i tried to run it alone, it's still the same result.

I may try to monitor the process name or whatever, not use the WaitForExit
again...

Thanks your hlep.

> I noticed you taked about cmd.exe ? What if you launch the real exe file
> instead ?
[quoted text clipped - 51 lines]
> >> > > That is
> >> > > what I would expect.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.