Closing a running executable

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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?
 
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?
 
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
 
Back
Top