Gunbuster Posted December 1, 2007 Share Posted December 1, 2007 I am currently using a batch file in combination with a VB Script to move computers from the default directory where they go when being added to the domain. I would like to rewrite this in AutoIt so that it has a more user friendly interface. Here is the VB Script I have been using. (I didn't write this. It was written by Chimera Computing Ltd) Option Explicit ' Declare variables dim objOU, objPC, objRootDSE, strDNSDomain dim sSourceCN, sDestCN, objNet, sThisComputer ' Find this computer name set objNet = CreateObject("WScript.NetWork") sThisComputer = objNet.ComputerName ' Get AD details set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("DefaultNamingContext") ' Set query source and destination sSourceCN = "LDAP://CN=" & sThisComputer & ",OU=Computers," & strDNSDomain sDestCN = "LDAP://OU=Division,OU=Region,OU=City,OU=Computers," & strDNSDomain ' Move computer object set objOU = GetObject(sDestCN) WScript.echo "Moving computer account" set objPC = objOU.MoveHere(sSourceCN, vbNullString) WScript.echo & sThisComputer $ " has successfully been moved to " & sDestCN & vbNewline I am new to AutoIt and have VERY LITTLE knowledge of VB Scripting. Any help with this is appreciated. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 1, 2007 Developers Share Posted December 1, 2007 (edited) I am currently using a batch file in combination with a VB Script to move computers from the default directory where they go when being added to the domain. I would like to rewrite this in AutoIt so that it has a more user friendly interface. Here is the VB Script I have been using. (I didn't write this. It was written by Chimera Computing Ltd) Option Explicit ' Declare variables dim objOU, objPC, objRootDSE, strDNSDomain dim sSourceCN, sDestCN, objNet, sThisComputer ' Find this computer name set objNet = CreateObject("WScript.NetWork") sThisComputer = objNet.ComputerName ' Get AD details set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("DefaultNamingContext") ' Set query source and destination sSourceCN = "LDAP://CN=" & sThisComputer & ",OU=Computers," & strDNSDomain sDestCN = "LDAP://OU=Division,OU=Region,OU=City,OU=Computers," & strDNSDomain ' Move computer object set objOU = GetObject(sDestCN) WScript.echo "Moving computer account" set objPC = objOU.MoveHere(sSourceCN, vbNullString) WScript.echo & sThisComputer $ " has successfully been moved to " & sDestCN & vbNewline I am new to AutoIt and have VERY LITTLE knowledge of VB Scripting. Any help with this is appreciated. Welcome to these forums . There are many posts on AD stuff .. just search and see if anything is useful for you to get you started. Moved to the correct Support forum . Jos Edited December 1, 2007 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 1, 2007 Share Posted December 1, 2007 I am currently using a batch file in combination with a VB Script to move computers from the default directory where they go when being added to the domain. I would like to rewrite this in AutoIt so that it has a more user friendly interface. Here is the VB Script I have been using. (I didn't write this. It was written by Chimera Computing Ltd) Option Explicit ' Declare variables dim objOU, objPC, objRootDSE, strDNSDomain dim sSourceCN, sDestCN, objNet, sThisComputer ' Find this computer name set objNet = CreateObject("WScript.NetWork") sThisComputer = objNet.ComputerName ' Get AD details set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("DefaultNamingContext") ' Set query source and destination sSourceCN = "LDAP://CN=" & sThisComputer & ",OU=Computers," & strDNSDomain sDestCN = "LDAP://OU=Division,OU=Region,OU=City,OU=Computers," & strDNSDomain ' Move computer object set objOU = GetObject(sDestCN) WScript.echo "Moving computer account" set objPC = objOU.MoveHere(sSourceCN, vbNullString) WScript.echo & sThisComputer $ " has successfully been moved to " & sDestCN & vbNewline I am new to AutoIt and have VERY LITTLE knowledge of VB Scripting. Any help with this is appreciated. Here's a conversion. Not tested because I'm not with my domains right now: Opt("MustDeclareVars", 1) Global $objOU, $objPC, $objRootDSE, $strDNSDomain Global $sSourceCN, $sDestCN, $objNet, $sThisComputer, $sMsg ; Find this computer name $objNet = ObjCreate("WScript.NetWork") $sThisComputer = $objNet.ComputerName ; Get AD details $objRootDSE = ObjGet("LDAP://RootDSE") $strDNSDomain = $objRootDSE.Get("DefaultNamingContext") ; Set query source and destination $sSourceCN = "LDAP://CN=" & $sThisComputer & ",OU=Computers," & $strDNSDomain $sDestCN = "LDAP://OU=Division,OU=Region,OU=City,OU=Computers," & $strDNSDomain ; Move computer object $objOU = ObjGet($sDestCN) $objPC = $objOU.MoveHere($sSourceCN, "") ; Report results $sMsg = "Moving computer account:" & @CRLF & _ $sThisComputer & " has successfully been moved to " & $sDestCN MsgBox(64, "Results", $sMsg) Cheers! 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...
Slarmo Posted September 3, 2008 Share Posted September 3, 2008 What about if the account you are using does not have rights to move computers. Can you add a line in the script to use different credentials? For instance to move the account when it is in the local admin account of the computer. 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