[Python] Unblock file programmatically that is created via win32com.client in Python on Windows

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am creating programmatically a shortcut using win32com.client.

    shell = win32com.client.Dispatch("WScript.Shell")
    shortcut = shell.CreateShortCut("foo")
    shortcut.Targetpath = "C:"
    shortcut.WorkingDirectory = "C:"
    shortcut.Arguments = " ".join(["my", "arguments"]


    The problem is now, that Windows marks this file as unsecure and pops up a window, whether the user really wants to run this potentially unsecure file. Using Unblock-File foo.lnk solves the problem.

    However, how can I already programmatically fix this during shortcut creation using win32com.client?

    Continue reading...

Compartilhe esta Página