Launching Wordpad on Windows

Adonis adonisv at REMOVETHISearthlink.net
Tue Jan 20 03:46:48 CET 2004


"Patrick L. Nolan" <pln at razzle.Stanford.EDU> wrote in message
news:buhtvp$l0j$1 at news.Stanford.EDU...
> I'm trying to find a clean way to launch a Wordpad editor
> on Windows.  By "clean", I mean that it should work on as
> many versions of Windows as possible, and it shouldn't
> require installing any extra software.  I assume everyone
> has win32api and its friends.
>
> The problem is to find the path to wordpad.exe.  At first
> I just copied the path from my XP machine:
> c:\Program Files\Windows NT\Accessories\WORDPAD.EXE
>
> I verified that the same path works on W2K, but I don't
> know about older versions.  With some labor I was able
> to come up with a longer, more obfuscated bit of code:
>
> item = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App
Paths\\WORDPAD.EXE"
> key = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, item, 0,
>   win32con.KEY_QUERY_VALUE)
> info = win32api.RegQueryValueEx(key, None)
> win32api.RegCloseKey(key)
> editor = win32api.ExpandEnvironmentStrings(info[0])
>
> I would like to solicit learned opinions about this.  Which
> version will work in more versions of Windows?  Is there a
> better approach?
>
> -- 
> *   Patrick L. Nolan                                          *
> *   W. W. Hansen Experimental Physics Laboratory (HEPL)       *
> *   Stanford University                                       *


This works for me:
(Using WinXP Pro)

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system("start wordpad")
0

Hope this helps.

Adonis





More information about the Python-list mailing list