Hi everybody
I need some help to finalize a script to rename many computers with netdom command.
I block on array
I have a file inf like this (Rename_Computer_Auto.inf) :
oldcomputer_name_01, newcomputer_name_01
oldcomputer_name_02, newcomputer_name_02
oldcomputer_name_03, newcomputer_name_03
oldcomputer_name_04, newcomputer_name_04
......
And here is my script but i have problem tu use array
Please could You help me ?
Sorry for my english
I need some help to finalize a script to rename many computers with netdom command.
I block on array
I have a file inf like this (Rename_Computer_Auto.inf) :
oldcomputer_name_01, newcomputer_name_01
oldcomputer_name_02, newcomputer_name_02
oldcomputer_name_03, newcomputer_name_03
oldcomputer_name_04, newcomputer_name_04
......
And here is my script but i have problem tu use array
[ autoit ]
Break(1) #region AUTOIT VARIABLES #include #include #include #include #include #include #endregion #region SCRIPT VARIABLES Local $NewComputerName,$OldComputerName,$avArray Local $ver="1.0" Local $blank='' Local $List=FileOpen('Rename_Computer_Auto.inf', 0) $log_file='Rename_Computer_Auto_'&@YEAR&'-'&@MON&'-'&@MDAY&'.log' $arraylist="" Local $DomainName="my domain" Local $AdminName="my account" Local $Password="my password" #endregion #region SCRIPT $GuiRun=GuiCreate("", 300, 60, -1, -1, $WS_POPUPWINDOW) $label1=GUICtrlCreateLabel("Renaming in progress for :", 0, 10, 300, 20, $SS_CENTER) $label2=GUICtrlCreateLabel("", 0, 30, 300, 20,$SS_CENTER) GUICtrlSetFont(-1, 9, 800) GUISetState(@SW_SHOW,$GuiRun) For $i = 1 To UBound($arraylist) - 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $avArray=StringSplit(FileReadLine($List,$i),",") If @error = -1 Then ExitLoop $OldComputerName=_ArrayToString($avArray, @TAB, 1, 1) $NewComputerName=_ArrayToString($avArray, @TAB, 2, 2) GUICtrlSetData($label2,$OldComputerName) $ping=Ping($OldComputerName) If $ping Then RunAs($AdminName,$DomainName,$Password,0,@ComSpec & " /c netdom renamecomputer "&$OldcomputerName&" /NewName:"&$NewComputerName&" /ud:"&$DomainName&"\"&$AdminName&" /PasswordD:"&$Password&" /Force") $intFile = FileOpen($log_file, 1) FileWriteLine($intFile, $OldcomputerName&' was renamed '&$NewComputerName&' on '&@YEAR&'-'&@MON&'-'&@MDAY&' at '&@HOUR&':'&@MIN&':'&@SEC) FileClose($intfile) Else $intFile = FileOpen($log_file, 1) FileWriteLine($intFile, $OldcomputerName&' was not renamed '&$NewComputerName&' because Host is offline or unreachable') FileClose($intfile) EndIf Next GUIDelete($GuiRun)
Please could You help me ?
Sorry for my english