[python-win32] win32com can't find file but I can see it, confused

Randy Syring rsyring at gmail.com
Fri Mar 9 18:44:11 CET 2012


Do you need to quote the value sent to shell.run() since there is a 
space in it?

shell.Run('"C:\Documents and 
Settings\dave\Desktop\MyMobile\MyMobiler\MyMobiler.exe"')

?

---------------------------------------------
Randy Syring
Development&  Executive Director
Level 12 Technologies  <https://www.lev12.com/>  (formerly Intelicom)
Direct: 502-276-0459
Office: 502-212-9913

Intelicom is now Level 12 Technologies,learn more about our name change  <https://www.lev12.com/our-history>.
Please update your address book with my new email address.

Principled People, Technology that Works


On 03/09/2012 08:17 AM, dave selby wrote:
> OK I am a little confused, I have the following
>
> shell = win32com.client.Dispatch('WScript.Shell')
> print os.path.isfile(self.exe)
> print self.exe
> shell.Run(self.exe)
>
> The file self.exe exists, I get a 'true' from os.path.isfile, I can
> execute it on the command line AOK, its path is as I would expect but
> when I attempt to execute it I get ...
>
> True
> C:\Documents and Settings\dave\Desktop\My Mobile\MyMobiler\MyMobiler.exe
> Traceback (most recent call last):
>   File "C:\Program Files\FX Hammer\core\diag.py", line 64, in<module>
>     my_mobiler_.startExe()
>   File "C:\Program Files\FX Hammer\core\my_mobiler.py", line 93, in startExe
>     shell.Run('C:\Documents and Settings\dave\Desktop\My
> Mobile\MyMobiler\MyMobiler.exe')
>   File "<COMObject WScript.Shell>", line 2, in Run
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None,
> None, None, 0, -2147024894), None)
>
> Now using win32api.FormatMessage() I get ...
>
> Exception occurred.
>
> The system cannot find the file specified.
>
> Am I missing anything ?
>
> Cheers
>
> Dave
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120309/5840a0a3/attachment.html>


More information about the python-win32 mailing list