executing VBScript from Python and vice versa
Valentina Boycheva
VBoycheva at jea.net
Thu Feb 10 11:50:20 EST 2005
A while ago I asked how VBScript can be called from Python. The two answers
I received suggested using win32com.client and
MSScriptControl.ScriptControl. This solution required embedding the VBScript
code inside the Python script.
Here's a shell approach that runs an existing VBScript file:
Python script
import os
import sys
os.system("F:\Projects\Doc\Scripts\VBScript\WriteDataToTextFile.vbs")
VBScript:
' WriteDataToTextFile.vbs
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\temp\temp.txt", ForAppending, True)
Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
objTextFile.WriteLine("My computer's name is")
objTextFile.WriteLine(objComputerName)
objTextFile.Close
More information about the Python-list
mailing list