473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Closing a running executable

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

Will launch x.txt in notepad

What code will close this instance of notepad?
Nov 18 '05 #1
4 1046
Process.Start() returns a Process instance. Call CloseMainWindow() or Kill()
on the returned instance.

"mg" <mg@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\notepad.exe","c:\\x
..txt");

Will launch x.txt in notepad

What code will close this instance of notepad?
Nov 18 '05 #2
mg
Thank you.
"Shiva" wrote:
Process.Start() returns a Process instance. Call CloseMainWindow() or Kill()
on the returned instance.

"mg" <mg@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\notepad.exe","c:\\x
..txt");

Will launch x.txt in notepad

What code will close this instance of notepad?

Nov 18 '05 #3
mg

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

System.Diagnostics.Process pr =
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\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?
"Shiva" wrote:
Process.Start() returns a Process instance. Call CloseMainWindow() or Kill()
on the returned instance.

"mg" <mg@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\notepad.exe","c:\\x
..txt");

Will launch x.txt in notepad

What code will close this instance of notepad?

Nov 18 '05 #4
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
"mg" wrote:

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

System.Diagnostics.Process pr =
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\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?
"Shiva" wrote:
Process.Start() returns a Process instance. Call CloseMainWindow() or Kill()
on the returned instance.

"mg" <mg@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
System.Diagnostics.Process.Start("c:\\windows\\sys tem32\\notepad.exe","c:\\x
..txt");

Will launch x.txt in notepad

What code will close this instance of notepad?

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Leon | last post by:
Is there any way to stop php.exe closing after it processes a PHP script? It doesn't seem to have the traditional options of an MS-DOS program. I am using Windows XP Pro and have associated .php...
6
by: Henrik Holm | last post by:
I have recently started playing around with Python. Some of the things I have done have involved reading files. The way I do this is along the lines of f = file('file.txt') lines =...
7
by: Johnny | last post by:
How do I create a link on a Web page on my hard drive that will run an executable file on my hard drive? For example, let's say I create runpoodle.htm and save it to my hard drive, and let's...
5
by: mg | last post by:
System.Diagnostics.Process.Start("c:\\windows\\system32\\notepad.exe","c:\\x.txt"); launches x.txt in notepad What code will close this instance of notepad?
0
by: Tam | last post by:
I have a problem trying to close a currently running executable. javaw.exe simply refuses to close. It is in the process list (confirmed by watching Processes in the task manager) and the code...
6
by: foldface | last post by:
Hi Sorry, don't know how to phrase the question any better. Within Visual Studio I have a style sheet that being dynamically added to the code, i.e. not via the html page. I want to place this...
17
by: Csaba Gabor | last post by:
Is there a way to determine the path to the php executable (as opposed to the script. In other words, I am looking for the path to php.exe or php-win.exe) that is currently running (ie. how was...
10
by: jon | last post by:
I am a beginner C programmer, this is actually my first programming lanugage, besides html, cgi, and javascript. I am looking for a way to make an .exe file, or a copy of my own file. I have tried...
4
by: Brad Pears | last post by:
I have a vb.net 2005 project and have made a lot of modifications to it. The project runs fine in debug mode. Now I want to implement it and first I am running the executable on my machine to make...
4
by: Perl Beginner | last post by:
Hello, I have written a VB program (VB 6.0) that is basically a GUI for the user to select from various buttons to run other executable files (which I wrote in Perl). When the Perl executable is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.