madmikep Posted May 1, 2007 Share Posted May 1, 2007 Hello, I have search for help on the following problem. This might be a bug. I have converted the following VBScript to Autoit and I am receiving the following error. The VBScript works fine but just can get it to work in AutoIT MoveComputer.au3 (39) : ==> The requested action with this object has failed.: $objOU.MoveHere ($strADsPath, "") $objOU.MoveHere ($strADsPath, "")^ ERROR The MsgBox command works and displays the current ADS Path. So I know it is connecting to AD and pulling information. When it hits the move command it falls. Any help would be greatly appreciated Note. Both login ID and ID used in the script have Domain Admin rights $wfID = "xxxxx" ; $CmdLine[1] $wfPass = "xxxxx" ;$CmdLine[2] Const $ADS_SCOPE_SUBTREE = 2 $objOU = ObjGet("LDAP://OU=Workstations,OU=Pasteur,OU=Corp,DC=wf,DC=local") $objConnection = ObjCreate("ADODB.Connection") $objCommand = ObjCreate("ADODB.Command") $objConnection.Provider = "ADsDSOObject" $objConnection.Properties ("User ID") = "wf\" & $wfID $objConnection.Properties ("Password") = $wfPass $objConnection.Properties ("Encrypt Password") = 1 $objConnection.Properties ("ADSI Flag") = 1 $objConnection.Open ("Active Directory Provider") $objCommand.ActiveConnection = $objConnection $objCommand.Properties ("Page Size") = 1000 $objCommand.Properties ("Searchscope") = $ADS_SCOPE_SUBTREE ; $objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://dc=WF,dc=local' WHERE objectCategory='computer' " & "AND Name='WF-6789'" $objCommand.CommandText = "SELECT ADsPath, distinguishedName, Name FROM 'LDAP://dc=WF,dc=local' WHERE objectCategory='computer' AND Name='WF-6789'" $objRecordSet = $objCommand.Execute $objRecordSet.MoveFirst () While Not $objRecordSet.EOF () $strADsPath = $objRecordSet.Fields ("ADsPath").Value MsgBox(4096, "", "Current path = " & $strADsPath) $objOU.MoveHere ($strADsPath, "") $objRecordSet.MoveNext () WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 1, 2007 Share Posted May 1, 2007 $objOU = ObjGet("LDAP://OU=Workstations,OU=Pasteur,OU=Corp,DC=wf,DC=local") ; ... While Not $objRecordSet.EOF () $strADsPath = $objRecordSet.Fields ("ADsPath").Value MsgBox(4096, "", "Current path = " & $strADsPath) $objOU.MoveHere ($strADsPath, "") $objRecordSet.MoveNext () WEndoÝ÷ Ûú®¢×ºÛayø«²Ûb쨺ëÓ~¨n3Êâ@1¶²hÄƲmèv'gßÛNn1µÊ+ç- Þnèç$jëh×6 $objOU = ObjGet("LDAP://OU=Workstations,OU=Pasteur,OU=Corp,DC=wf,DC=local") If IsObj($objOU) Then MsgBox(64, "Debug", "$objOU is object.") Else MsgBox(16, "Debug", "$objOU is not an object!") EndIf ; ... While Not $objRecordSet.EOF () $strADsPath = $objRecordSet.Fields ("ADsPath").Value MsgBox(4096, "", "Current path = " & $strADsPath) $objOU.MoveHere ($strADsPath, "") $objRecordSet.MoveNext () WEnd 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...
Valuater Posted May 1, 2007 Share Posted May 1, 2007 (edited) I have not used ".MoveHere" before, however I would think this line should be different $objOU.MoveHere ($strADsPath, "") is either $objOU.MoveHere ($strADsPath) or..... $objOU.MoveHere ($strADsPath, "C:\location\folder\") ... move from "here" to "here" idea 8) Edited May 1, 2007 by Valuater Link to comment Share on other sites More sharing options...
madmikep Posted May 1, 2007 Author Share Posted May 1, 2007 (edited) PsaltyDS Thanks, Object is reporting as correct If IsObj($objOU) Then MsgBox(64, "Debug", "$objOU is object.") Else MsgBox(16, "Debug", "$objOU is not an object!") EndIf Valuater Thanks, The format for .MoveHere ($strADsPath, "") is object reference .MoveHere(parameter 1, parameter 2) First parameter is the current location of the object Second parameter is used for renaming the object during the move, But sine I am not renaming the object I pass a Null variable as the second parameter. Edited May 1, 2007 by madmikep Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 1, 2007 Share Posted May 1, 2007 ValuaterThanks, The format for .MoveHere ($strADsPath, "") is object reference .MoveHere(parameter 1, parameter 2)First parameter is the current location of the objectSecond parameter is used for renaming the object during the move, But sine I am not renaming the object I pass a Null variable as the second parameter.Hmm... from this site: IADsContainer::MoveHereIn Visual Basic applications, you can pass vbNullString as the second parameter when moving an object from one container to another. Set newobj = cont.MoveHere("LDAP://cn=jeffsmith,ou=sale,dc=dom,dc=com", vbNullString)However, you cannot do the same with VBScript. This is because VBScript maps vbNullString to an empty string instead of to a null string, as does Visual Basic. You must use the RDN explicitly, as shown in the previous example.That brings me to something I don't know... is there a difference in AutoIt between true null and "" (empty string)... 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...
madmikep Posted May 1, 2007 Author Share Posted May 1, 2007 Here is the VBscript that works correctly CODEobjOU.MoveHere strADsPath, vbNullString Convert it to Autoit should be CODE$objOU.MoveHere($strADsPath,"") I have evey tried $objOU.MoveHere($strADsPath,"vbNullString") with the same error I think this might be a bug in AutoIt, but not sure. CODEOn Error Resume Next Const ADS_SCOPE_SUBTREE = 2 Set objOU = GetObject("LDAP://OU=Workstations,OU=Pasteur,OU=Corp,DC=wf,DC=local") Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT ADsPath FROM 'LDAP://dc=WF,dc=local' WHERE objectCategory='computer' " & "AND Name='WF-6789'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF strADsPath = objRecordSet.Fields("ADsPath").Value objOU.MoveHere strADsPath, vbNullString objRecordSet.MoveNext Loop Link to comment Share on other sites More sharing options...
jefhal Posted May 1, 2007 Share Posted May 1, 2007 From the MS "ScriptingGuys" site:By the way, you dont actually have to include the Null parameter; if theres no second parameter MoveHere will assume the second parameter is Null. We show it here just so you know that MoveHere accepts two parameters. ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
jefhal Posted May 1, 2007 Share Posted May 1, 2007 Did you consider: $objOU.MoveHere ('"' & $strADsPath & '"', "") That is putting singlequote doublequote singlequote around the value in $strADsPath... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 1, 2007 Share Posted May 1, 2007 (edited) Here is the VBscript that works correctly objOU.MoveHere strADsPath, vbNullString Convert it to Autoit should be $objOU.MoveHere($strADsPath,"") I have evey tried $objOU.MoveHere($strADsPath,"vbNullString") with the same error I think this might be a bug in AutoIt, but not sure. In some spheres, NUL is a special case. It's not 0 or "", it's nothing. But I don't know if that applies to AutoIt variables. Some things to try: First, as jefhal has recommended, try quotes around the first value, and try leaving the second parameter off entirely. To go off on my NUL tangent, you could try: Dim $Nul ; no preset value at all $objOU.MoveHere($strADsPath,$Nul)oÝ÷ ØêÚºÚ"µÍ[H ÌÍÓ[HÚ NÈ][[ÈÈÙ[]H[ÌÍÛØÕK[ÝRJ ÌÍÜÝQÔ] ÌÍÓ[ oÝ÷ ØêÞ½éÚºÚ"µÍ[H ÌÍÓ[H[JÚ JNÈ][[ÈÈÙ[]H[ÌÍÛØÕK[ÝRJ ÌÍÜÝQÔ] ÌÍÓ[ I've gone off the deep end and this may be a wild goose chase, sorry... Edited May 1, 2007 by PsaltyDS 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...
madmikep Posted May 2, 2007 Author Share Posted May 2, 2007 (edited) From the MS "ScriptingGuys" site:By the way, you donât actually have to include the Null parameter; if thereâs no second parameter MoveHere will assume the second parameter is Null. We show it here just so you know that MoveHere accepts two parameters.Thanks, jefhalBut,This would not be the first time that the ScriptingGuys gave out incorrect information. I ran across a script that they published that did not work correctly they for got to include a Set command for a GetobjectIF you do not include the second parameter in the VBscript it will error out âunless you have an ON Error resume notâ with the following error âWindows Script Hostâ WSH. Error: Wrong number of arguments or invalid property assignment: objOU.MoveHere code 800A01c2 The second parameter is required Edited May 2, 2007 by madmikep Link to comment Share on other sites More sharing options...
madmikep Posted May 2, 2007 Author Share Posted May 2, 2007 Did you consider: $objOU.MoveHere ('"' & $strADsPath & '"', "") That is putting singlequote doublequote singlequote around the value in $strADsPath... Thanks again, I did try this with the same result $objOU.MoveHere ('"' & $strADsPath & '"', "") Link to comment Share on other sites More sharing options...
madmikep Posted May 2, 2007 Author Share Posted May 2, 2007 (edited) In some spheres, NUL is a special case. It's not 0 or "", it's nothing. But I don't know if that applies to AutoIt variables. Some things to try: First, as jefhal has recommended, try quotes around the first value, and try leaving the second parameter off entirely. To go off on my NUL tangent, you could try: Dim $Nul ; no preset value at all $objOU.MoveHere($strADsPath,$Nul)oÝ÷ ØêÚºÚ"µÍ[H ÌÍÓ[HÚ NÈ][[ÈÈÙ[]H[ÌÍÛØÕK[ÝRJ ÌÍÜÝQÔ] ÌÍÓ[ oÝ÷ ØêÞ½éÚºÚ"µÍ[H ÌÍÓ[H[JÚ JNÈ][[ÈÈÙ[]H[ÌÍÛØÕK[ÝRJ ÌÍÜÝQÔ] ÌÍÓ[ I've gone off the deep end and this may be a wild goose chase, sorry... PsaltyDS, I also try the Dims no go and just for the hell of it I even tried Dim $Nul = Dec("00") Edited May 2, 2007 by madmikep Link to comment Share on other sites More sharing options...
ptrex Posted May 2, 2007 Share Posted May 2, 2007 @all is this a good hint ? $objOU.MoveHere($strADsPath,Default) regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
madmikep Posted May 2, 2007 Author Share Posted May 2, 2007 @all is this a good hint ? $objOU.MoveHere($strADsPath,Default) regards ptrex Thnaks,ptrex But no go on that keyword Link to comment Share on other sites More sharing options...
CyberSlug Posted November 19, 2007 Share Posted November 19, 2007 (edited) I know this is an old thread, but I'm posting the following for reference purposes: ;Seems to work... $computerName = @ComputerName ;Change as needed $strNewParentDN = "LDAP://OU=Accounting,OU=Administrative,DC=example,DC=com" $strObjectDN = "LDAP://CN=" & $computerName & ",OU=machines,DC=example,DC=com" $strObjectRDN = "CN=" & $computerName $objCont = ObjGet($strNewParentDN) $objCont.MoveHere($strObjectDN, $strObjectRDN) Edited November 19, 2007 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! 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