pshankland Posted January 17, 2012 Share Posted January 17, 2012 (edited) Hi all, I am trying to convert the following lines of VBScript into AutoIT: Const strDomainName = "localhost" Const strAccountValidDays = 7 Set Manager = CreateObject("G6FTPServer.Manager") Set Domain = Manager.Domains.Item(strDomainName) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell") Set objArgs = WScript.Arguments Looking through the help files and forum posts I have got the following: $strDomainName = "localhost" $strAccountValidDays = 7 Local $objManager = ObjCreate("G6FTPServer.Manager") Local $objDomain = $objManager.Domains.Item($strDomainName) Local $objFSO = ObjCreate("Scripting.FileSystemObject") Local $objShell = ObjCreate("WScript.Shell") Local $objArgs = WScript.Arguments However, the above is incorrect as when the code runs the 'Local objDomain = objManager.Domains.Item(strDomainName)' or 'Local objArgs = WScript.Arguments' part I get the following error: Error: Missing separator character after keyword. Can anyone point me in the right direction? Thanks. Pete. Edited January 17, 2012 by pshankland Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 (edited) Try:Global $strDomainName = "Globalhost" Global $strAccountValidDays = 7 Global $objManager = ObjCreate("G6FTPServer.Manager") Global $objDomain = $objManager.Domains.Item($strDomainName) Global $objFSO = ObjCreate("Scripting.FileSystemObject") Global $objShell = ObjCreate("WScript.Shell") Global $objArgs = ObjGet("Wscript.Arguments") I'm not sure about the last statement. Maybe this can be replaced by $CmdLine. Edited January 17, 2012 by water pshankland 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pshankland Posted January 17, 2012 Author Share Posted January 17, 2012 (edited) Well, I don't get errors again However, when I now progress to actually add something in I get an error. Original VBScript: Const strDomainName = "localhost" Const strAccountValidDays = 7 Set Manager = CreateObject("G6FTPServer.Manager") Set Domain = Manager.Domains.Item(strDomainName) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell") Set objArgs = WScript.Arguments strRealName = objArgs.Item(0) strEmail = objArgs.Item(1) Set User = Domain.UserList.Add(strEmail) AutoIT Code: #include <windowsconstants.au3> #Include <array.au3> #include <date.au3> Global $strDomainName = "localhost" Global $strAccountValidDays = 7 Global $objManager = ObjCreate("G6FTPServer.Manager") Global $objDomain = $objManager.Domains.Item($strDomainName) Global $objFSO = ObjCreate("Scripting.FileSystemObject") Global $objShell = ObjCreate("WScript.Shell") Global $objArgs = ObjGet("WScript.Arguments") $strRealName = InputBox("Real Name", "Users Real Name:") $strEmail = InputBox("Email", "Users Email Address:") Local $strUser = $objDomain.UserList.Add($strEmail) Have included the error as a screenshot. Any clues? Thanks. Edited January 17, 2012 by pshankland Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 (edited) You need a COM error handler. Try this:#include <windowsconstants.au3> #Include <array.au3> #include <date.au3> Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $strDomainName = "localhost" Global $strAccountValidDays = 7 Global $objManager = ObjCreate("G6FTPServer.Manager") Global $objDomain = $objManager.Domains.Item($strDomainName) Global $objFSO = ObjCreate("Scripting.FileSystemObject") Global $objShell = ObjCreate("WScript.Shell") Global $objArgs = ObjGet("WScript.Arguments") $strRealName = InputBox("Real Name", "Users Real Name:") $strEmail = InputBox("Email", "Users Email Address:") Local $strUser = $objDomain.UserList.Add($strEmail) ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Edited January 17, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pshankland Posted January 17, 2012 Author Share Posted January 17, 2012 Got the following output now: err.number is: 2 err.windescription: Not an Object type err.description is: err.source is: err.helpfile is: err.helpcontext is: 0 err.lastdllerror is: 0 err.scriptline is: 26 err.retcode is: 0 Had a quick look to see what the "Not an Object type" error would be but am stuck again. Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 Try this:#include <windowsconstants.au3> #Include <array.au3> #include <date.au3> Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $strDomainName = "localhost" Global $strAccountValidDays = 7 Global $objManager = ObjCreate("G6FTPServer.Manager") ConsoleWrite("G6FTPServer.Manager: @error: " & @error & ", @extended: " & @extended & @CRLF) Global $objDomain = $objManager.Domains.Item($strDomainName) ConsoleWrite("$objManager.Domains.Item($strDomainName): @error: " & @error & ", @extended: " & @extended & @CRLF) Global $objFSO = ObjCreate("Scripting.FileSystemObject") ConsoleWrite("Scripting.FileSystemObject: @error: " & @error & ", @extended: " & @extended & @CRLF) Global $objShell = ObjCreate("WScript.Shell") ConsoleWrite("WScript.Shell: @error: " & @error & ", @extended: " & @extended & @CRLF) Global $objArgs = ObjGet("WScript.Arguments") ConsoleWrite("WScript.Arguments: @error: " & @error & ", @extended: " & @extended & @CRLF) $strRealName = InputBox("Real Name", "Users Real Name:") $strEmail = InputBox("Email", "Users Email Address:") Local $strUser = $objDomain.UserList.Add($strEmail) ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFuncBTW: Do you thing "localhost" is the correct input for a field named "$strDomainName"? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pshankland Posted January 17, 2012 Author Share Posted January 17, 2012 BTW: Do you thing "localhost" is the correct input for a field named "$strDomainName"?Ahhhhhhh, that's the problem! I was using localhost as a test instead of the actual domain name used within Gene6 FTP Server. Changed it to the correct server name and it went through So sorry about missing that Thanks for the help. Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 Glad we could solve the problem My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pshankland Posted January 17, 2012 Author Share Posted January 17, 2012 Another question (sorry) In VBScript I have the following which checks to see if the Email address exists and adds various values if it doesnt: If Domain.UserList.Item(strEmail) is Nothing Then Set User = Domain.UserList.Add(strEmail) User.Properties.Values("Enabled") = "1" User.Properties.Values("Password") = ":" & strPassword 'Add : to password to force as plain text User.Properties.Values("RealName") = strRealName User.Properties.Values("Email") = strEmail User.Properties.Values("AccessList") = "/," & strHomeFolder & ",R,FDI" User.Properties.Values("ExpirationEnabled") = "1" User.Properties.Values("ExpirationDate") = strUserExpiration User.Properties.Values("Scripts") = "Log downloads.vbs"&vbCRLF&"Log uploads.vbs" 'Msgbox("User " & strEmail & " has been created") Else 'Msgbox("User " & strEmail & " already exists") WScript.Quit End If I have the following in AutoIT but the 'IF' statement is wrong as doesn't process correctly (just tries to add each time): If $objDomain.UserList.Item($strEmail) <> $strEmail Then Local $strUser = $objDomain.UserList.Add($strEmail) $strUser.Properties.Values("Enabled") = "1" $strUser.Properties.Values("Password") = ":" & $strPassword ;Add : to password to force as plain text $strUser.Properties.Values("RealName") = $strRealName $strUser.Properties.Values("Email") = $strEmail $strUser.Properties.Values("AccessList") = "/," & $strHomeFolder & ",R,FDI" $strUser.Properties.Values("ExpirationEnabled") = "1" $strUser.Properties.Values("ExpirationDate") = $strExpireDate $strUser.Properties.Values("Scripts") = "Log downloads.vbs" & Chr(13) & "Log uploads.vbs" MsgBox(0,"Output", "Real Name: " & $strRealName & Chr(13) _ & "Email: " & $strEmail & Chr(13) _ & "Password: " & $strPassword & Chr(13) _ & "Home Folder: " & $strHomeFolder & Chr(13) _ & "Expiration Date: " & $strExpireDate) Else MsgBox(0,"", "User already exists") EndIf What would be the equivalent in AutoIT for 'Is Nothing Then'? Thanks for the ongoing support! Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 I think the Item method returns an object. So you would check forIf Not Isobj($objDomain.UserList.Item($strEmail)) Then pshankland 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pshankland Posted January 17, 2012 Author Share Posted January 17, 2012 Amazing, works like a charm Not sure if anyone will want it but I'll make sure I post my completed code once finished. Thanks again. Link to comment Share on other sites More sharing options...
water Posted January 17, 2012 Share Posted January 17, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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