jcchipper2 Posted November 15, 2008 Posted November 15, 2008 I'm trying to convert this small VB script to autoit3 and have hit a snag at the very end: VB Script: set env = CreateObject("Microsoft.SMS.TSEnvironment") Name = inputbox("Enter OS Selection: XP or Vista" ,"OS Selection:",env("OSType"),400,0) env("OSType") = Name AutoIT: CODE#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $oShell Opt('MustDeclareVars', 1) OSDetect() Func OSDetect() Local $msg, $button_1, $OSType, $name GUICreate("OS Deploy", 300, 125) GUICtrlCreateLabel("Select Operating System to Deploy: XP or Vista", 20, 20, 170, 40) $OSType = GUICtrlCreateCombo("", 30, 80, 100, 10) ; create first item GUICtrlSetData(-1, "XP|Vista") ; add other item snd set a new default $button_1 = GUICtrlCreateButton("Okay", 170, 65, 120, 40) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 $oShell = ObjCreate("Microsoft.SMS.TSEnvironment") $name = GUICtrlRead($OSType) MsgBox(0,"I have semi worked", $name) $oShell("OSType") = $name ExitLoop EndSelect WEnd EndFunc When I run the above code I get: Line -1: Error: Expected a "=" operator in assignment statement I know the code is failing after the Msgbox. Any help would be appreciated.
mmavipc Posted November 15, 2008 Posted November 15, 2008 $name = $oShell("OSType") [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N
wraithdu Posted November 16, 2008 Posted November 16, 2008 It's failing because $oShell is not an object, meaning your ObjCreate() failed. I don't think AutoIt can access this COM object.
jcchipper2 Posted November 17, 2008 Author Posted November 17, 2008 Thanks for the reply's. I wound up just cheating CODE#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> Dim $File Opt('MustDeclareVars', 1) OSDetect() Func OSDetect() Local $msg, $button_1, $MachineName, $name GUICreate("OS Deploy", 300, 125, 0, 0) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel("Enter Machine Name:", 20, 10, 170, 40) ; first cell 70 width $MachineName = GUICtrlCreateInput("", 0, 35, 300, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $button_1 = GUICtrlCreateButton("Okay", 170, 65, 120, 40) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button_1 $name = GUICtrlRead($MachineName) If FileExists(@ScriptDir & "\MachineName.vbs") Then FileDelete (@ScriptDir & "\MachineName.vbs") EndIf _FileCreate (@ScriptDir & "\MachineName.vbs") $File = FileOpen (@ScriptDir & "\MachineName.vbs", 2) FileWriteLine($File, "set env = CreateObject(""Microsoft.SMS.TSEnvironment"")") FileWriteLine($File, "env(""OSDComputerName"") = " & """" & $name &"""") FileClose($file) RunWait(@ComSpec & " /c " & "MachineName.vbs") ExitLoop EndSelect WEnd EndFunc
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