Where is Word?
guy.lateur at b-b.be
Thu Jun 16 16:38:58 CEST 2005
Ok, I've tried various proposed solutions, and this is what I've come up
# get Word path
wordKey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths', 0, win32con.KEY_READ)
wPath = win32api.RegQueryValue(wordKey, 'winword.exe')
# open/write tempfile & delete afterwards
fD, fN = tempfile.mkstemp('.txt')
fH = os.fdopen(fD, 'w')
os.spawnl(os.P_WAIT, wPath, 'winword.exe', fN)
The above seems to work ok, but if you run the script a second time without
first closing Word(1), the os.spawnl() doesn't seem to block. As a
consequence, the tempfile is not removed (because Word still has it open
when os.remove(fN) is called).
Is this behaviour normal? Anything I can do about this?
More information about the Python-list