The following code opens a text file in notepad and then closes notepad ...
as desired.
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo("c:\\windows\\ system32\\notepad.exe","c:\\x.txt");
p.StartInfo = psi;
p.Start();
p.CloseMainWindow();
But, the following code opens a pdf file in the Acrobat reader but then does
not close the Acrobat reader.
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo("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""");
p.StartInfo = psi;
p.Start();
p.CloseMainWindow();
How can I close this Acrobat reader programatically?
"Arne Janning" wrote:
Hi!
"mg" schrieb System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\notepad.exe","c:\\x.txt");
launches x.txt in notepad
What code will close this instance of notepad?
//You need a reference to the process
Process p = new Process();
ProcessStartInfo psi =
new ProcessStartInfo(
"c:\\windows\\system32\\notepad.exe");
p.StartInfo = psi;
//Start notepad
p.Start();
//Sleep five seconds
System.Threading.Thread.Sleep(5000);
//Close notepad again
p.CloseMainWindow();
Cheers
Arne Janning