I want to ask few questions about win32com.client
.
What does DisPatch
do? It returns COMObject wscript.shell
. What exactly is this?
shell = win32com.client.Dispatch("wscript.shell")
And why do we use it while creating shortcut.
shortcutcut = shell.CreateShortcut('shortcut.lnk')
win32com.client.Dispatch
creates a ActiveX/COM object. The argument is the so-called program ID. Another example of program ID is "Excel.Application" which would be used to create an instance of Excel. In your case you are creating a wscript.shell
object.
The program ID is mapped to a DLL on the system by the registry. The object is instantiated through a number of well-known export methods.
Apparently, one of the methods of a wscript.shell object is CreateShortcut. Why you are using a wscript.shell to do this, I can't say.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.