from win32com.client import Dispatch
#ref : http://mow001.blogspot.com/2006/03/vbscript-hosting-in-msh-inputbox-in.html
vbs = Dispatch("MSScriptControl.ScriptControl")
vbs.Language = "vbscript";
wmi= r"""
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT Caption,Size FROM Win32_LogicalDisk where drivetype='3'",,48)
"""
ldisque = []
def cleanString(s):
car = [';','"','\n','\t',' ']
for c in car:
try:
s = s.replace(c,'')
except:
continue
head = s.index('{')
tail = s.index('}')
s = s.replace(':',',')
s = s.replace('=',':')
return s
vbs.addcode(wmi)
col = vbs.eval('colItems')
for item in col:
disque = item.GetObjectText_()
print cleanString(disque)
vbs = None
Monday, November 26, 2007
VBS from Python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment