I'm not sure about .wsf, but in ASP (which uses windows scripting) only one
interpreter runs at a time, so Python probably runs first before the
VBScript interpreter. This is why it is not generally recommended to mix
languages within one ASP page.
To pass by reference in Python, you assign the variables instead of passing
them as parameters. Also, once your script is written, you have to run the
script "makepy.py -i", and a prompt listing all the COM objects will
appear. You then select the COM you are using, and makepy creates a CLSID
that you use in your script.
For Example:
makepy generates something like this:
{2A1A4BD8-921D-11D3-8889-000629D0EE15}, lcid=0, major=3, minor=0
>>> # Use these commands in Python code to auto generate .py support
>>> from win32com.client import gencache
>>> gencache.EnsureModule('{2A1A4BD8-921D-11D3-8889-000629D0EE15}', 0, 3,
0)
so use this in your script:
from win32com.client import gencache
gencache.EnsureModule('{2A1A4BD8-921D-11D3-8889-000629D0EE15}', 0, 3, 0)
from win32com.client import Dispatch
com = Dispatch("Your.COM")
foo = com.bar()
You only have to call makepy when you need the CLSID, then you can use it
as long as its registered on your machine. I highly recommend "Python
Programming on Win32" from O'Reilly, if you don't already have it. There's
a whole section about this topic.
Good luck,
-Ryan
"Carl Petersen"
<[EMAIL PROTECTED]> To:
<[EMAIL PROTECTED]>
Sent by: cc:
[EMAIL PROTECTED] Subject: Scope
question when using WHS and COM
eState.com
03/22/01 09:42 AM
Hopefully I have the correct mailing list.
When combining VBscript, Jscript, and Python in a windows scripting file
(.wsf) the python script sections ignore the globals declared in other
script sections. Is there a way around this behavior?
Example test.wsf
<job>
<script language="VBScript">
Public variable
</script>
<script language="Python">
print "variable = ",variable (when executed variable is
undefined)
</script>
</job>
Also is there anyway around pythons inability to interface with com objects
whose methods pass parameters by reference? VBScript defaults to pass by
ref
so it works and I would like create a wrapper in vbscript which could be
called from python. This does not seem to work because of the above global
scope issue.
TIA
Carl petersen
Opticominc.com
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython