473,386 Members | 1,766 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,386 software developers and data experts.

Start application & continue after app exits

Hi all,

I was wondering if it would be possible to launch an application, block
until the app exits, and do some cleanup afterwards.

Maybe an example will be clearer: I would like to make a temperary (text)
file, open it with MS Word for the user to edit/layout/print, and then
delete the temp file after the user shuts down Word. Is this feasible?

Thanks,
g
Jul 19 '05 #1
1 1339
Guy Lateur wrote:
I was wondering if it would be possible to launch an application, block
until the app exits, and do some cleanup afterwards. Maybe an example will be clearer: I would like to make a temperary (text)
file, open it with MS Word for the user to edit/layout/print, and then
delete the temp file after the user shuts down Word. Is this feasible?


Something like:

import os
import tempfile

testString = "Life is but a dream."
fileName = tempfile.mktemp()
print fileName
open(fileName, "w").write(testString)
os.system("gedit %s" % fileName)
os.remove(fileName)

---
Note that I'm on Linux, and instead of launching Word I'm launching an
editor named "gedit". You could likely change that call to winword.exe,
but I haven't tested it on Windows.

Also note that this method of creating tempfiles is technically unsafe,
as it is theoretically possible that another process would create a file
of the same name in the same directory and then try to use it, resulting
in a race condition between the two processes. This is practically
unlikely, however, and I'm a pragmatist.
--
Paul McNett
http://paulmcnett.com

Jul 19 '05 #2

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

Similar topics

2
by: Krish | last post by:
This is my first attempt, please bear. I referenced Excel 10.0 Object from VS .NET IDE, I think this creates Interop Object for Excel. I have the following code. ------code start---- ...
3
by: Bob Rock | last post by:
Hello, this is something I've been asking myself for sometime ... and now I'd like to clarify this point. When should the try block start in a method??? What I mean is, does having all the code...
4
by: Bob Day | last post by:
Using VS 2003, VB.Net, MSDE... The example below from help shows that the Sub Main contains an explicit Application.Run. Is this required? Are there pros and cons of doing it this way? I have...
5
by: Matthew Hood | last post by:
I have a DLL I created to handle all unknown errors using the Application.ThreadException event. I'm asking the user if they want to terminate the program or continue. This is working like I...
20
by: joseph_gallagher | last post by:
Hi, I've recently ported a .Net 1.1 application to .Net 2.0 and the one new feature that is getting on my nerves is that when there is an unhandled exception the application completely crashes,...
2
by: sani8888 | last post by:
Hi everybody I am a beginner with C++ programming. And I need some help. How can I start with this program *********** The program is using a text file of information as the source of the...
1
by: cvairetti | last post by:
Hi, I just write an application in C# that show an interface with five button, each button starts an external application that it comes in front of the main C# application with focus on. When the...
2
by: askvb6 | last post by:
while installing a package developed in Package & deployment wizard, I get the following error message "Some system files are out of date whether you want to continue installing" If we say yes it 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.