win32com - Python - Create Shortcut with arguments -


using win32com.client, i'm attempting create simple shortcut in folder. shortcut have arguments, except keep getting following error.

traceback (most recent call last):   file "d:/projects/ms/ms.py", line 153, in <module>     scut.targetpath = '"c:/python27/python.exe" "d:/projects/ms/msd.py" -b ' + str(loop7)  file "c:\python27\lib\site-packages\win32com\client\dynamic.py", line 570, in __setattr__     raise attributeerror("property '%s.%s' can not set." % (self._username_, attr)) attributeerror: property '<unknown>.targetpath' can not set. 

my code looks this. i've tried multiple different variates can't seem right. doing wrong?

ws = win32com.client.dispatch("wscript.shell") scut = ws.createshortcut("d:/projects/ms/testdir/testlink.lnk") scut.targetpath = '"c:/python27/python.exe" "d:/projects/ms/msd.py" -b 0' scut.save() 

your code works me without error. (windows xp 32bit, python 2.7.5, pywin32-216).

(i modified code because targetpath should contain executable path.)

import win32com.client ws = win32com.client.dispatch("wscript.shell") scut = ws.createshortcut('run_idle.lnk') scut.targetpath = '"c:/python27/python.exe"' scut.arguments = '-m idlelib.idle' scut.save() 

i got attributeerror similar yours when tried following (assign list arguments property.)

>>> scut.arguments = [] traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "c:\python27\lib\site-packages\win32com\client\dynamic.py", line 570, in __setattr__     raise attributeerror("property '%s.%s' can not set." % (self._username_, attr)) attributeerror: property '<unknown>.arguments' can not set. 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -