473,467 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

executing VBScript from Python and vice versa

Is there a way to make programs written in these two languages communicate
with each other? I am pretty sure that VBScript can access a Python script
because Python is COM compliant. On the other hand, Python might be able to
call a VBScript through WSH. Can somebody provide a simple example? I have
exactly 4 days of experience in Python (and fortunately, much more in VB6)

Thanks.

Jul 18 '05 #1
3 9112
Go to the bookstore and get a copy of Python Programming on Win32
by Mark Hammond, Andy Robinson today.

http://www.oreilly.com/catalog/pythonwin32/

It has everything you need.
Is there a way to make programs written in these two languages
communicate
with each other? I am pretty sure that VBScript can access a Python
script
because Python is COM compliant. On the other hand, Python might be able
to
call a VBScript through WSH. Can somebody provide a simple example? I
have
exactly 4 days of experience in Python (and fortunately, much more in
VB6)

Thanks.


Jul 18 '05 #2
Valentina Boycheva wrote:
Is there a way to make programs written in these two languages communicate
with each other? I am pretty sure that VBScript can access a Python script
because Python is COM compliant. On the other hand, Python might be able to
call a VBScript through WSH. Can somebody provide a simple example? I have
exactly 4 days of experience in Python (and fortunately, much more in VB6)

Thanks.


This should help for Python accessing VBScript,
import win32com.client
vbhost = win32com.client.Dispatch("ScriptControl")
vbhost.language = "vbscript"
vbhost.addcode("Function two(x)\ntwo=2*x\nEnd Function\n")
vbhost.eval("two(2)") 4


Alternatively you could try to convert your VBScript to Python.

http://vb2py.sourceforge.net/demo.htm

Regards,

Paul
Jul 18 '05 #3
Cool. :-)

And it's OK, also, for JScript (MS-Javascript) :
import win32com.client

vbs = win32com.client.Dispatch("ScriptControl")
vbs.language = "vbscript"
scode="""Function mul2(x)
mul2=x*2
End Function
"""
vbs.addcode(scode)
print vbs.eval("mul2(123)")

js = win32com.client.Dispatch("ScriptControl")
js.language = "jscript"
scode="""function mul3(x){
vret=x*3;
return(vret);
}
function mul4(x){
vret=x*4;
return(vret);
}
"""
js.addcode(scode)
print js.eval("mul3(123);")
print js.eval("mul4(121);")

@-salutations
--
Michel Claveau

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Valentina Boycheva | last post by:
Thanks for the reply. I already have "Learning Python" from Mark Lutz and David Ascher, which covers 2.3 (I am in 2.4). However, it seems like heavy artillery to me. What I want is, for instance,...
1
by: Dharmendra Singh | last post by:
Hi I'm using .Net(C#) and working on the form(Screen) which have text boxes for both arabic and english data to store. So i want to change the language at run time from arabic to english and...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
6
by: David | last post by:
Hi, I have a script in one of my .asp pages which I think is written in VBScript (I did not write it). I would like to know how to do the following in Javascript. Have a combo on my page...
2
by: Steve - DND | last post by:
Just wondering if anyone out there has any code to convert a plural word to it's singular form and vice versa. Most of our database tables are named in a plural fashion. When we go to create...
112
by: mystilleef | last post by:
Hello, What is the Pythonic way of implementing getters and setters. I've heard people say the use of accessors is not Pythonic. But why? And what is the alternative? I refrain from using them...
1
by: r_o | last post by:
hi, im using FileSystemObject's File object to create an html file and write it to the webserver's disk and then send it as a mail attachment. final_draft="<!DOCTYPE html PUBLIC ""-//W3C//DTD...
1
by: Cameron Laird | last post by:
QOTW: "... ow that I've made the switch to python, I'm several orders of magnitude more productive ..." - Rob Knapp http://groups.google.com/group/comp.lang.python/msg/8a4efd549bfb451a "Hanging...
20
by: Mr.SpOOn | last post by:
Hi, I need a structure to represent a set of integers. I also need to perform on this set some basic set operations, such as adding or removing elements, joining with other sets and checking for...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.