Create shortcut files in Windows 7 using Python

前端 未结 5 1125
天命终不由人
天命终不由人 2021-02-08 18:07

Is there a simple way to create shortcuts in Windows 7 on Python? I looked it up online but they did not seem that simple.

I have tried using this simple method:

<
5条回答
  •  清歌不尽
    2021-02-08 18:19

    What you are doing currently is creating the equivalent of an empty file (in this case a shortcut) on your computer within your current working directory.

    To make this file a usable shortcut, you will need to write some information to the file you are creating that tells windows what this shortcut file is going to do. In this case, that would be what type of shortcut you want it to run and any other arguments necessary to accomplish the task at hand.

    I believe pywin32 will come in handy for most of these tasks: http://sourceforge.net/projects/pywin32/

    If you are creating an internet shortcut, an example of that can be found on this page (using pywin32): http://www.blog.pythonlibrary.org/2010/01/23/using-python-to-create-shortcuts/

    If you are looking to create something other than an internet shortcut, you will need need to lookup the appropriate windows command for the type of shortcut you want to run (e.g. open a particular application or specific file).

提交回复
热议问题