Hallo,
ich versuche gerade mit Python eine .lnk Datei unter Windows zu öffnen...
Ich bekomme zwar einen String zurück, aber leider irgendiwe im falschen Format. Wie kann ich .lnk Dateien öffnen und herausfinden, wohin sie verweisen?
Danke!
.lnk Dateien öffnen
Das sollte wohl weiterhelfen:
http://msdn.microsoft.com/en-us/library/bb774950(VS.85)
http://timgolden.me.uk/python/win32_how ... rtcut.html
MfG
HWK
http://msdn.microsoft.com/en-us/library/bb774950(VS.85)
http://timgolden.me.uk/python/win32_how ... rtcut.html
MfG
HWK
Code: Alles auswählen
from win32com.shell import shell
import pythoncom
link_paths = []
regexp = re.compile('.*\.lnk$', re.IGNORECASE)
for root, dirs, files in os.walk('C:\\'):
for file in files:
if regexp.match(file) != None:
link_path = os.path.join(root, file)
link_paths.append(link_path)
shell_link = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
link = shell_link.QueryInterface(pythoncom.IID_IPersistFile)
for link_path in link_paths:
link.Load(link_path)
shell_link.Resolve(0, 0)
file_link = shell_link.GetPath(shell.SLGP_UNCPRIORITY)[0]
if os.path.exists(file_link) != True and file_link != '':
logging.info(link_path)
logging.info(file_link)
Soweit funtkioniert das auch schon. Nur leider wird jedes mal ein Windows Fenster geöffnet, welches auch geöffnet wird, wenn man auf eine solche Verknüpfung klickt (Durchsuchen,...)
Irgndwie öffnet er also diese Datei wirklich - wie kann ich das verhindern?
Vielen Dank für eure Hilfe!