By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Launching multiple instances of a program with win32com.client.Dispatch?

P: n/a
Hi there, I am trying to launch a program called AmiBroker using the
command:

AB = win32com.client.Dispatch("Broker.Application")

However, I have a dual-core CPU and would like to launch two instances
of AmiBroker. I know it is possible to run two instances simultaneously
since it is easy to do manually by double-clicking the AmiBroker.exe
file twice. However, when I write two lines of code like this:

AB = win32com.client.Dispatch("Broker.Application")
AB2 = win32com.client.Dispatch("Broker.Application")

and proceed to address these objects, they interfere with each other
since both AB and AB2 are "grabbing" the same instance of AmiBroker. If
I try to run two separate Python scripts, each one containing a
"win32com.client.Dispatch("Broker.Application" )" comand, the same
problem happens (where even though the objects are named differently,
they do not each launch an instance of the program; the first one
launches it and the second one just "grabs" it).

Does anyone know how to force two separate program launches rather than
having both Dispatch commands access the same object? I would be
incredibly thankful to anyone who could offer some help with this.

Thank you very much,

Tyler

Jul 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
win32com.client.DispatchEx should create a new instance.

Roger

<ty*************@gmail.comwrote in message news:11**********************@s26g2000cwa.googlegr oups.com...
Hi there, I am trying to launch a program called AmiBroker using the
command:

AB = win32com.client.Dispatch("Broker.Application")

However, I have a dual-core CPU and would like to launch two instances
of AmiBroker. I know it is possible to run two instances simultaneously
since it is easy to do manually by double-clicking the AmiBroker.exe
file twice. However, when I write two lines of code like this:

AB = win32com.client.Dispatch("Broker.Application")
AB2 = win32com.client.Dispatch("Broker.Application")

and proceed to address these objects, they interfere with each other
since both AB and AB2 are "grabbing" the same instance of AmiBroker. If
I try to run two separate Python scripts, each one containing a
"win32com.client.Dispatch("Broker.Application" )" comand, the same
problem happens (where even though the objects are named differently,
they do not each launch an instance of the program; the first one
launches it and the second one just "grabs" it).

Does anyone know how to force two separate program launches rather than
having both Dispatch commands access the same object? I would be
incredibly thankful to anyone who could offer some help with this.

Thank you very much,

Tyler

Jul 7 '06 #2

P: n/a
Hi Roger,

Thanks for the response, but DispatchEx seems to do the exact same
thing as Dispatch in my case; there is still only one processID and one
instance of my program (I forgot to mention that I also need two unique
processID's to keep track of them).

I have also tried:

###

AB1 =
pythoncom.CoCreateInstance("Broker.Application",No ne,pythoncom.CLSCTX_SERVER,pythoncom.IID_IDispatch )

AB2 =
pythoncom.CoCreateInstance("Broker.Application",No ne,pythoncom.CLSCTX_SERVER,pythoncom.IID_IDispatch )

win32com.client.Dispatch(AB1)
win32com.client.Dispatch(AB2)

###

That also seems to do the exact same thing.

Any other ideas of things I might try?

Roger Upole wrote:
win32com.client.DispatchEx should create a new instance.

Roger

<ty*************@gmail.comwrote in message news:11**********************@s26g2000cwa.googlegr oups.com...
Hi there, I am trying to launch a program called AmiBroker using the
command:

AB = win32com.client.Dispatch("Broker.Application")

However, I have a dual-core CPU and would like to launch two instances
of AmiBroker. I know it is possible to run two instances simultaneously
since it is easy to do manually by double-clicking the AmiBroker.exe
file twice. However, when I write two lines of code like this:

AB = win32com.client.Dispatch("Broker.Application")
AB2 = win32com.client.Dispatch("Broker.Application")

and proceed to address these objects, they interfere with each other
since both AB and AB2 are "grabbing" the same instance of AmiBroker. If
I try to run two separate Python scripts, each one containing a
"win32com.client.Dispatch("Broker.Application" )" comand, the same
problem happens (where even though the objects are named differently,
they do not each launch an instance of the program; the first one
launches it and the second one just "grabs" it).

Does anyone know how to force two separate program launches rather than
having both Dispatch commands access the same object? I would be
incredibly thankful to anyone who could offer some help with this.

Thank you very much,

Tyler
Jul 7 '06 #3

P: n/a
Bump...not sure if it's bad etiquette here, I apologize if it is.
ty*************@gmail.com wrote:
Hi Roger,

Thanks for the response, but DispatchEx seems to do the exact same
thing as Dispatch in my case; there is still only one processID and one
instance of my program (I forgot to mention that I also need two unique
processID's to keep track of them).

I have also tried:

###

AB1 =
pythoncom.CoCreateInstance("Broker.Application",No ne,pythoncom.CLSCTX_SERVER,pythoncom.IID_IDispatch )

AB2 =
pythoncom.CoCreateInstance("Broker.Application",No ne,pythoncom.CLSCTX_SERVER,pythoncom.IID_IDispatch )

win32com.client.Dispatch(AB1)
win32com.client.Dispatch(AB2)

###

That also seems to do the exact same thing.

Any other ideas of things I might try?

Roger Upole wrote:
win32com.client.DispatchEx should create a new instance.

Roger

<ty*************@gmail.comwrote in message news:11**********************@s26g2000cwa.googlegr oups.com...
Hi there, I am trying to launch a program called AmiBroker using the
command:
>
AB = win32com.client.Dispatch("Broker.Application")
>
However, I have a dual-core CPU and would like to launch two instances
of AmiBroker. I know it is possible to run two instances simultaneously
since it is easy to do manually by double-clicking the AmiBroker.exe
file twice. However, when I write two lines of code like this:
>
AB = win32com.client.Dispatch("Broker.Application")
AB2 = win32com.client.Dispatch("Broker.Application")
>
and proceed to address these objects, they interfere with each other
since both AB and AB2 are "grabbing" the same instance of AmiBroker. If
I try to run two separate Python scripts, each one containing a
"win32com.client.Dispatch("Broker.Application" )" comand, the same
problem happens (where even though the objects are named differently,
they do not each launch an instance of the program; the first one
launches it and the second one just "grabs" it).
>
Does anyone know how to force two separate program launches rather than
having both Dispatch commands access the same object? I would be
incredibly thankful to anyone who could offer some help with this.
>
Thank you very much,
>
Tyler
>
Jul 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.