Creating windows shortcuts

Matt Gerrans matt_gerrans at hp.com
Wed Aug 14 20:15:37 EDT 2002


The WScript.shell COM automation object is also pretty simple to use:

import os, win32com.client
shell = win32com.client.Dispatch('WScript.shell')
desktop = shell.SpecialFolders('Desktop')

shorty = shell.CreateShortcut( os.path.join(desktop,'It Works, By
Golly!.lnk'))

shorty.TargetPath = os.path.join(os.environ['systemroot'],'Notepad.exe')
shorty.WindowStyle = 1
shorty.Hotkey = "CTRL+SHIFT+F"
shorty.IconLocation = "notepad.exe, 0"
shorty.Description = "Shortcut Script"
shorty.WorkingDirectory = desktop

shorty.Save()

- Matt






More information about the Python-list mailing list