DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   python script works in pywin but not in command window (http://www.daniweb.com/forums/thread156779.html)

gab_sk Nov 12th, 2008 4:23 am
python script works in pywin but not in command window
 
Hi,

I have a python script which uses a COM object. This script works correctly when I run it from pywin, however, it does not run when I run it from windows command line - it throws an exception occurred in this COM object.
I know that this COM obj. exception is also thrown when call is made from C++ code, but this can be avoided when some specific resource is added to C++ project (after project rebuild it works).
I don't know how to achieve the same effect (as with C++ solution) with python and also I don't know what pywin is doing differently so that this code works there.

Any help is appreciated.

Thank you.

jlm699 Nov 12th, 2008 6:52 am
Re: python script works in pywin but not in command window
 
Can you provide some code to demonstrate the problem? It will be much easier to understand the problem

gab_sk Nov 12th, 2008 8:03 am
Re: python script works in pywin but not in command window
 
This is the code, very short and simple, exception occurs in login.ValidateUser(). When I run this in pythonwin, process id is printed in interactive window, so it works as expected.

import win32com.client

login = win32com.client.Dispatch("ACDB.Login")
login.Login("","")
login.ApplicationName = "whatever"
login.Version = "1.0"
login.ValidateUser("Sunrise.fxb")
print login.ProcessID

jlm699 Nov 12th, 2008 9:26 am
Re: python script works in pywin but not in command window
 
Can you also post the traceback of the exception?


All times are GMT -4. The time now is 6:14 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC