Closing a running executable

G

Guest

System.Diagnostics.Process.Start("c:\\windows\\system32\\notepad.exe","c:\\x.txt");

Will launch x.txt in notepad

What code will close this instance of notepad?
 
S

Shiva

Process.Start() returns a Process instance. Call CloseMainWindow() or Kill()
on the returned instance.

System.Diagnostics.Process.Start("c:\\windows\\system32\\notepad.exe","c:\\x
..txt");

Will launch x.txt in notepad

What code will close this instance of notepad?
 
G

Guest

The following 2 lines open a text file in notepad and then close notepad:

System.Diagnostics.Process pr =
System.Diagnostics.Process.Start("c:\\windows\\system32\\notepad.exe","c:\\x.txt");

pr.CloseMainWindow();

But, the following 2 lines open a pdf file in the Acrobat reader, which
remains open:

System.Diagnostics.Process pr =
System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t ""c:\exportfiles\d.pdf"" ""HP LaserJet 3300
Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

pr.CloseMainWindow();

How can I close the Acrobat reader?
 
G

Guest

I needed to do this same thing and have been searching for it. I thank you
for having the issue prior to me. I did however figure out how to get the
Acrobat window to disappear. Just do the following...

pr.CloseMainWindow();
pr.Close();

Apparently doing both completely clears everything.
Kevin
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top