maxcronjob Posted May 19, 2005 Posted May 19, 2005 Hi all, I wrote an autoit script to do some installation verification testing and along with the .exe I also have four separate .vbs scripts that it calls to perform various functions within the AutoIt test. I'm looking for suggestions on how I can "fold" these .vbs scripts into my AutoIt script, or, maybe consolidate these .vbs scripts into one script, is that possible? -max
MSLx Fanboy Posted May 19, 2005 Posted May 19, 2005 Can you post them? If they are using COM, autoit now supports COM functionality (at least beta versions). You could also do a FileInstall() if you want to keep the vbs in its original format, instead of having to convert it. Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
SvenP Posted May 19, 2005 Posted May 19, 2005 Hi all, I wrote an autoit script to do some installation verification testing and along with the .exe I also have four separate .vbs scripts that it calls to perform various functions within the AutoIt test. I'm looking for suggestions on how I can "fold" these .vbs scripts into my AutoIt script, or, maybe consolidate these .vbs scripts into one script, is that possible? -max<{POST_SNAPBACK}>I know that several solutions were found by others to run VBscript inside AutoIt3:1. Using "RunWait("Wscript.exe " + Name of your script.2. Using AutoIt COM extensions: $vbs = ObjCreate("ScriptControl") See: http://www.autoitscript.com/forum/index.php?showtopic=104933. By just rewriting the VBscript to AutoIt3 syntax. (e.g. removing the 'Set' keyword, adding '$' signs to variable names, etc. I had plans once to write a 'VBscript to AutoIt3' tutorial, but time is still against me.Pick your choice.Regards,-Sven
maxcronjob Posted May 20, 2005 Author Posted May 20, 2005 These are the scripts I'm using. Actually there are only 3: 1. listusers.vbs: On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_UserAccount Where LocalAccount = True") For Each objItem in colItems Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Caption: " & objItem.Caption Wscript.Echo "Description: " & objItem.Description Wscript.Echo "Disabled: " & objItem.Disabled Wscript.Echo "Domain: " & objItem.Domain Wscript.Echo "Full Name: " & objItem.FullName Wscript.Echo "Local Account: " & objItem.LocalAccount Wscript.Echo "Lockout: " & objItem.Lockout Wscript.Echo "Password Changeable: " & objItem.PasswordChangeable Wscript.Echo "Password Expires: " & objItem.PasswordExpires Wscript.Echo "Password Required: " & objItem.PasswordRequired Wscript.Echo "Status: " & objItem.Status Wscript.Echo Next ============================= 2. listvolumes.vbs strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDiskPartitions = objWMIService.ExecQuery _ ("Select * from Win32_DiskPartition") For each objPartition in colDiskPartitions objPartition.Size = objPartition.Size /1000000 WScript.Echo " " WScript.Echo"Bootable? " & VBTab & objPartition.Bootable WScript.Echo"Boot Partition: " & objPartition.BootPartition WScript.Echo"Description: " & VBTab & objPartition.Description WScript.Echo"Device ID: " & VBTab & objPartition.DeviceID WScript.Echo"Disk Index: " & VBTab & objPartition.DiskIndex WScript.Echo"Index: " & VBTab & VBTab & objPartition.Index WScript.Echo"Partition Size: " & objPartition.Size & " MB" WScript.Echo"Type: " & VBTab & VBTab & objPartition.Type Next ' End of Script =================================== 3. listserial.vbs strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colBIOS = objWMIService.ExecQuery _ ("Select * from Win32_BIOS") For each objBIOS in colBIOS Wscript.Echo "Serial Number: " & objBIOS.SerialNumber Next ====================================
MSLx Fanboy Posted May 20, 2005 Posted May 20, 2005 (edited) I have/had a script working for your first script, it only works in the most current versions of the 3.1.1+ beta P.S. I attached a file that has a few conversion from VBScript to AutoIt, its still a work in progress. If anyone gets any further on this (especially in email function), let me know, I need all the help I can get! expandcollapse popup$oMyErr = ObjEvent("AutoIt.Error","MyErrFunc") $colUser = ObjGet("WinNT://" & @ComputerName & "") if @error then Msgbox(0,"AutoItCOM ADSI Test","Failed to open WinNT://. Error code: " & hex(@error,8)) exit endif dim $Array[1] ; Our filter array $Array[0]="user" ; We only include 'groups' in this filter $colUser.Filter = $Array ; Apply filter if not isobj($colUser) then msgbox(0,"Grouptest","$colUser is not an object") exit endif For $oUser In $colUser ; MsgBox(0, "test", $oUser.Name) MsgBox(0, "test", "Name: " & $oUser.Name & @CRLF & _ "Description: " & $oUser.Description & @CRLF & _ "Disabled: " & $oUser.Disabled & @CRLF & _ "Domain: " & $oUser.Domain & @CRLF & _ "Full Name: " & $oUser.FullName & @CRLF & _ "Local Account: " & $oUser.LocalAccount & @CRLF & _ "Lockout: " & $oUser.Lockout & @CRLF & _ "Password Changeable: " & $oUser.PasswordChangeable & @CRLF & _ "Password Expires: " & $oUser.PasswordExpires & @CRLF & _ "Password Required: " & $oUser.PasswordRequired & @CRLF & _ "Status: " & $oUser.Status) Next ;### Tidy Error: Level error -> "For" Not closed before Func statement. ;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement. Func MyErrFunc() $hexnum=hex($oMyErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $oMyErr.description & @CRLF & _ "err.windescription is: " & $oMyErr.windescription & @CRLF & _ "err.lastdllerror is: " & $oMyErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $oMyErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $oMyErr.source & @CRLF & _ "err.helpfile is: " & $oMyErr.helpfile & @CRLF & _ "err.helpcontext is: " & $oMyErr.helpcontext _ ) Seterror(1) EndFunc ;==>MyErrFunc #cs For $oUser in $colAccounts $prompt = "Name: " & $oUser.Name & _ "Caption: " & $oUser.Caption & _ "Description: " & $oUser.Description & _ "Disabled: " & $oUser.Disabled & _ "Domain: " & $oUser.Domain & _ "Full Name: " & $oUser.FullName & _ "Local Account: " & $oUser.LocalAccount & _ "Lockout: " & $oUser.Lockout & _ "Password Changeable: " & $oUser.PasswordChangeable & _ "Password Expires: " & $oUser.PasswordExpires & _ "Password Required: " & $oUser.PasswordRequired & _ "Status: " & $oUser.Status & _ MsgBox(0, "test", $prompt) Next #ce I keep getting errors when running on my computer (COM errors). If someone figures that out, feel free to correct me...I keep erroring on the line with the MsgBox() statementaccounts.au3 Edited May 20, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
SvenP Posted May 20, 2005 Posted May 20, 2005 These are the scripts I'm using. Actually there are only 3:1. listusers.vbs:....====================================<{POST_SNAPBACK}>Hello maxcronjob,Since they are all WMI based scripts, you could try to re-generated them using the AutoIt scriptomatic tool:http://www.autoitscript.com/forum/index.php?showtopic=10534This tools is nearly the same as Microsofts scriptomatic, but this one generates AutoIt scripts.Regards,-Sven
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now