Remo1075 Posted October 24, 2009 Share Posted October 24, 2009 Hi and Thanks for any help... I am trying to convert the below VBS script (which works) to an Autoit script. The current vbs script brings up a cscript window and an input box but I want to convert it so I can have it run without showing a black cscript window in the backgroud and just an input box. 'VBS Code Option Explicit Dim wshArguments, objUser, strCurrentID, strLegalID, objSchemaLegalName On Error Resume Next Set wshArguments = WScript.Arguments Set objUser = GetObject(wshArguments(0)) Set objSchemaLegalName = GetObject("LDAP://schema/extensionAttribute1") If objUser.extensionAttribute1 <> "" Then strCurrentID = objUser.extensionAttribute1 Else strCurrentID = "empty" End If strLegalID = InputBox( _ "The current Legal Name is " & strCurrentID & vbCrLf & _ vbCrLf & _ "Enter the new Legal Name (1 through 1024 chars)", _ Right(objUser.Name, Len(objUser.Name) - 3) & " Legal Name", _ objUser.extensionAttribute1) If strLegalID = "" Then WScript.Quit Err.Clear objUser.extensionAttribute1 = strLegalID objUser.SetInfo If Err Then MsgBox "The new Legal Name was not saved.", _ vbCritical, "Error Occurred" ;Autoit Code AutoItSetOption("MustDeclareVars", 1) Dim $wshArguments, $objUser, $strCurrentID, $strLegalID, $objSchemaLegalName $wshArguments = $CmdLine $objUser = ObjGet($wshArguments(0)) $objSchemaLegalName = ObjGet("LDAP://schema/extensionAttribute1") If $objUser.extensionAttribute1 <> "" Then $strCurrentID = $objUser.extensionAttribute1 Else $strCurrentID = "empty" EndIf $strLegalID = InputBox( _ "The current Legal Name is " & $strCurrentID & @CRLF & _ @CRLF & _ "Enter the new Legal Name (1 through 1024 chars)", _ StringRight($objUser.Name, StringLen($objUser.Name) - 3) & " Legal Name", _ $objUser.extensionAttribute1)() ;If $strLegalID = "" Then WScript.Quit ;VA $Err.Clear $objUser.extensionAttribute1 = $strLegalID $objUser.SetInfo() If $Err Then MsgBox "The new Legal Name was not saved.", _ $vbCritical, "Error Occurred" Thanks again for any help Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 24, 2009 Share Posted October 24, 2009 To start with: 1. $CmdLine is an array of parameters, which you copy to $wshArguments and then use invalid syntax for array reference. 2. Element [0] of $CmdLine (and therefore $wshArguments) is a count, not the first argument. 3. You have prompt text in the title parameter of your InputBox(), and the title can't be multi-line. 4. The rest of the parameters for InputBox() look wrong and then you have a stray "()". 5. Syntax is wrong on your MsgBox(). All of this is trivial to fix an indicates you haven't made even a cursory check of the help file for correct syntax and usage of those functions. Read the help file and run the simple tutorial there, try the example scripts in the help file for the functions you want to try and use. Do the fuller tutorial linked in sig. You won't have any problem working with AutoIt after doing those things. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Remo1075 Posted October 24, 2009 Author Share Posted October 24, 2009 To start with: 1. $CmdLine is an array of parameters, which you copy to $wshArguments and then use invalid syntax for array reference. 2. Element [0] of $CmdLine (and therefore $wshArguments) is a count, not the first argument. 3. You have prompt text in the title parameter of your InputBox(), and the title can't be multi-line. 4. The rest of the parameters for InputBox() look wrong and then you have a stray "()". 5. Syntax is wrong on your MsgBox(). All of this is trivial to fix an indicates you haven't made even a cursory check of the help file for correct syntax and usage of those functions. Read the help file and run the simple tutorial there, try the example scripts in the help file for the functions you want to try and use. Do the fuller tutorial linked in sig. You won't have any problem working with AutoIt after doing those things. Thanks for the pointers, to be honest I used a vbs to autoit converter thinking that whoever wrote it must be smarter than me...and that maybe the rest of the problems were just small things or slightly incorrect syntax. Link to comment Share on other sites More sharing options...
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