[python-win32] How to call Python methods and properties from VBS?

FT Chester_Lab at fltg.net
Fri Sep 9 02:23:59 CEST 2011


Hi Mark,

    I am aware of the registering issue and the demo listed a path to
pointed to every location where that .DLL or .exe file may be located. It
was as if it got installed everywhere; assuming that both the compiled and
install path of Python is also being shown.

    The IE problem is not the problem, for I downloaded the files, not once,
but twice, and each time when using windows to run the .exe file the same
error comes up. It also will ask for a password, yet none of my other
executables I download ask that question. In other words, I am not running
it from IE.

    I have downloaded Portable Python because it's packages has all these
packages inside of it. I don't know when I will use that version. But it
sounds like a real good alternative for running Python and all packages.

    I am getting back hopefully tomorrow afternoon my Del latest XP computer
which was in repair, rebuilt. That version may open these files but I just
don't think so. My old computer I am using now just has an old version of my
screen reader program and only SP1 of any Windows stuff. Maybe that is the
issue, but that does not explain failure of only these .exe files and none
of my other downloads on different pages of that same web site for Python
downloads. Some difference is some are .sy, but still only these files give
me any grief.

    Once I get my better computer back I will experiment with the files and
registering Python as shown. For this computer will not have Python loaded
onto it until I do so and will be able to test to see if it in fact does
work when compiled and registered.

    My old computer I have no desire to change anything since it does
compile and things run, but as attempting to update the win32 stuff, it
dies...attempting to install them.

    All I can see right now is to compile on the old and run them on the new
as if Python did not exist. Once confident I can do this I will then install
Python, maybe; or use Portable Python.

    I guess the question to ask is, have you had any problems with Portable
Python? That's if you have run it.

        Sincerely
        Bruce


Sent: Thursday, September 08, 2011 8:02 PM
Subject: Re: [python-win32] How to call Python methods and properties from
VBS?


On 8/09/2011 11:20 PM, FT wrote:
> Mark,
>
> This script:
> set interp = CreateObject("Python.Interpreter")
> interp.Exec "import sys"
>
>      Is this not calling a local computers installation of Python?

If you built a DLL via py2exe and registered that, then it will not be
using the local installation of Python but a copy of Python which py2exe
has packaged up.  That is basically the entire point of py2exe.

>
>      I read over several times the Py2Exe docs and the chapter 12 stuff on
> making the .dll and .exe. I always compile with both being made and test
my
> programs and they work fine.
>
>      This example that you pointed me to and I had already read seems to
> indicate that the Python is already on that computer by calling that
> CreateObject method.
>
>      It does not answer my original question, for looking around it seems
all
> examples assume the Python is already installed.
>
>      I read the way you use specific commands inside all definitions to
> indicate what you want to expose and not expose, but where is the complete
> example of someone installing th e .dll and or .exe into a machine that
does
> not have Python and registering assuming that?

A py2exe created package does not need Python installed to work.
However, it also doesn't perform the actual installation - you want
something like nsis or inno for that.

>
>      Question number 2, I attempted to download the latest win32 packages
one
> compiled/built July 2009 and May of this year. In both cases I could not
> install the .exe and the error was saying both are corrupted!

I have heard that internet explorer can get upset with the installation
files for some reason - can you try a different browser?  Or even try
and start the installer executable from Windows itself instead of via
IE?  FWIW, the files on sourceforge are fine.

>      Now, I need a direct link to the actual download and not a third
party,
> jump, moved to another page link, for I think I may have been directed to
a
> virus loaded page to download these files.

The files are hosted on sourceforge and they often redirect you to a
mirror.  I'm afraid I'm not sure of what the canonical location of the
"actual download" is, but I'd be very very surprised if one of their
mirrors added a virus.

Cheers,

Mark

>      So, I need a good example on what I had asked below and the page to
have
> the latest Python2.5 com and win32 packages to run with, for I have only
> 2007 versions on my computer.
>
>          Sincerely
>          Bruce
>
>
> Sent: Tuesday, September 06, 2011 12:24 AM
> Subject: Re: [python-win32] How to call Python methods and properties from
> VBS?
>
>
> Please keep replies on the python-win32 list - others may also be able
> to help you too.
>
> You might like to check out the sample in samples\pywin32\com_server in
> the py2exe distribution - that demonstrates a simple COM object and has
> a VBScript sample which calls it.
>
> Hope this helps,
>
> Mark
>
> On 6/09/2011 1:38 PM, FT wrote:
>>
>> Hi Mark,
>>
>>       I wanted to have the python and other modules from a py2exe
> accessible
>> from vb script. So I would need to have the best documentation on how to
> set
>> up the python com library to be able to call it from vb script. This is
> not
>> using a web server, but inside a screen reader script language. The one I
> am
>> using is Windoweyes Scripting language which has all or most windows
> methods
>> and the external xml file for screen displays.
>>
>>       I am a blind programmer and use the screen reader with a built in
vb
>> script programming language. So, knowing Python I want to be able to call
>> those module methods at will. I have made executables but they reside in
a
>> sub directory of Windoweyes and are limited to only what the .exe file
> does
>> and not flexible beyond that point.
>>
>>       I was given snap shots of examples but they are very spotty and
> actual
>> say they show a vb script example, but none was displayed.
>>
>>       I am assuming that you have to make a class for all the modules you
> want
>> to be able to call, but not really sure on that. I have spent all evening
>> trying to find examples and such and came up with almost nothing but an
> old
>> activestate 2.4 brief description which said little on what to do.
>>
>>       So, this is where I am at the moment and have found little to
explain
>> fully what to do. It showed a way to set up the py2exe but the so called
>> example call from vb script was not there but it said it was. The typical
>> hello script example.
>>
>>       So, what I need is a very good tutorial on how to step by step make
> the
>> class and compile it to a distributle so it can be registered and called
> as
>> a com or automation call from vb script. Using what I would assume to be
> the
>> CreatObject command in vbs to make an instance of that
> object/module/method.
>>
>>       I am blind, so no pictures, I need just plain text to do it.
>>
>>           Sincerely
>>           Bruce
>>
>> Sent: Monday, September 05, 2011 6:51 PM
>> Subject: Re: [python-win32] How to call Python methods and properties
from
>> VBS?
>>
>>
>> On 4/09/2011 11:35 PM, FT wrote:
>>> Hi Again,
>>> To be more specific I have compiled the Python inside a distributed
>>> package and need to know how to call from within that compiled package
>>> any method. In other words do I have to register the Python inside my
>>> .vbs script before calling any methods?
>>> I am saying this so another user does not need to install Python, just
>>> call using com inside the distributed Python compiled version.
>>> If so, how do I get the Python setup or in a form to call? I will be
>>> doing all the calls from .VBS and how would the CreateObject from there
>>> be done to setup to call the compiled Python interpreter?
>>
>> You should develop and test using normal Python, then once you want to
>> distribute it to others, look into py2exe to "compile" it and an
>> installer program such as nsis or inno so the user can simply install it.
>>
>> Hope this helps,
>>
>> Mark
>>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32




More information about the python-win32 mailing list