Jump to content

Ghost21

Active Members
  • Posts

    387
  • Joined

  • Last visited

Everything posted by Ghost21

  1. Water and JCHD, With both of your recommendations has resulted in a 200MB file to be completed in under 2mins.. This will be a great time saver of like weeks of manual labor.
  2. Thank you both for the insight. In changing the $SIF to open the file and append I went from 3hrs of run time on a 200MB file to 2.75mins of run time.. I appreciate all the help.
  3. Well here is the issue I have written a conversion tool for SubinACL. Essentially what I'm doing is exporting all them groups/Members then reading the export file doing some filtering etc. and writing the file back to the clean file. Now in doing this some of the file exports are 1.5GB in size and take many hours to run. Can someone please look at the code and see if you can find anything glaring that I could clean up to improve performance. #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <String.au3> Global $LS = InputBox("Local Server Name", "What server are you migrating from local groups:" & @CRLF & "eg. contosofilesvr", "") If $LS = "" Then Exit Global $Domain = InputBox("Domain Name", "What domain are you migrating permissions to:" & @CRLF & "eg. contoso", "") If $Domain = "" Then Exit Global $SEF = FileOpenDialog("SubinACL Export File", @ScriptDir, "Text files (*.txt)", "", "") If FileExists($SEF) Then MsgBox(0, "SubinACL Export File.", "Confirmed. " & $SEF) Else MsgBox(0, "SubinACL Export File is Missing or not created.", "Please correct this issue. Exiting") Exit EndIf Global $SIF = FileOpenDialog("Subinacl Import File", @ScriptDir, "Text files (*.txt)", "", "") If FileExists($SIF) Then MsgBox(0, "SubinACL Import File.", "Confirmed. " & $SIF) Else MsgBox(0, "SubinACL Import File is missing or not created.", "Please correct this issue. Exiting") Exit EndIf Global Const $MF = @ScriptDir & "\" & "Members.csv" If FileExists($MF) Then MsgBox(0, "Local Groups Export File.", "Confirmed. " & $MF) Else MsgBox(0, "Local Groups Export File is missing or not created.", "Please correct this issue. Exiting") Exit EndIf $timer = TimerInit() FindACL() ConsoleWrite(TimerDiff($timer) & @CRLF) Func FindACL() $file = FileOpen($SEF, 512) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $SplitString = StringSplit($line, " ") For $i = 1 To $SplitString[0] $SearchString = StringSplit($SplitString[$i], "\") For $k = 1 To $SearchString[0] If $SearchString[$k] = "=" & $LS Then $lgss = $SearchString[$k + 1] LocalGroups($lgss, $line) EndIf Next Next If StringLeft($line, 9) <> "/pace =S-" Then If StringLeft($line, 15) <> "/pace =everyone" Then If StringLeft($line, 20) <> "/pace =builtin\users" Then If StringLeft($line, 16) <> "/pace =" & $LS Then WriteSameData($line) EndIf EndIf EndIf EndIf WEnd FileClose($file) EndFunc ;==>FindACL Func LocalGroups($lgss, $line) $aInput = "" _FileReadToArray($MF, $aInput) For $i = 2 To UBound($aInput) - 1 $output = StringSplit($aInput[$i], ",") $LG = StringTrimRight(StringTrimLeft($output[2], 1), 1) If $LG = $lgss Then $M = StringTrimRight(StringTrimLeft($output[3], 1), 1) $M = StringSplit($M, ";") For $C = 1 To $M[0] $FM = $M[$C] If $FM <> "" Then If StringLeft($FM, 9) <> "S-1-5-21-" Then $newdata = StringReplace($line, "=" & $LS & "\" & $lgss, "=" & $Domain & "\" & $FM) WriteData($newdata) EndIf EndIf Next EndIf Next EndFunc ;==>LocalGroups Func WriteData($newdata) FileWriteLine($SIF, $newdata) EndFunc ;==>WriteData Func WriteSameData($line) FileWriteLine($SIF, $line) EndFunc ;==>WriteSameData
  4. I don't know what I was smokin on that one but yours is a sexy thing.. Thank you
  5. First off I know I have a whole bunch of includes that don't pertain to the script... Its just a testing window I use.. I'm trying to get the users names that appear to show up so then I can move the profiles. But no matter what checkbox I select it doesn't show me the right name back.. ???????????? Help Please!! #include <AD.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstants.au3> #include <GuiConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GuiToolbar.au3> #include <GuiTreeView.au3> #include <GuiStatusBar.au3> #include <ListViewConstants.au3> #include <Math.au3> #include <Misc.au3> #include <NetShare.au3> #include <Process.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <Timers.au3> #include <TreeViewConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <Mysql.au3> #include <string.au3> #include <GDIPlus.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 700, 438, 192, 124) $Button1 = GUICtrlCreateButton("Remove from Discovery", 510, 8, 169, 25) $ListView1 = GUICtrlCreateListView("User|Sid", 8, 8, 480, 425, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTASCENDING), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_TRACKSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 170) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 378) ;_GUICtrlListView_AddItem( $xx = "" $sids = "" $Checkbox = "" $Userandsid = "" $text = "" $Column = "" $Columns = "" $sArray = "" For $i = 1 To 100 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileList", $i) If @error <> 0 Then ExitLoop $sids = $var & "," & $sids Next $sids = StringSplit(StringTrimRight($sids, 1), ",") For $x = $sids[0] To 1 Step -1 $userprofilepath = RegRead("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileList" & $sids[$x], "ProfileImagePath") $user = StringSplit($userprofilepath, "") $usernumber = $user[0] $Userandsid = $user[$usernumber] & "|" & $sids[$x] & "," & $Userandsid GUICtrlCreateListViewItem($user[$usernumber] & "|" & $sids[$x], $ListView1) Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $state = '' For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1 If _GUICtrlListView_GetItemChecked($ListView1, $i) Then $state = $state & ',' & $i EndIf Next $State = StringTrimLeft($state,1) $statesplit = StringSplit($state, ",") For $d = 1 To $statesplit[0] If $statesplit[$d] <> '' Then $number = StringStripWS($statesplit[$d], 15) msgbox(0,"",$number) $item = _GUICtrlListView_GetItemSelected($ListView1, $number) $textofitem = _GUICtrlListView_GetItemText($ListView1, $item) MsgBox(0, $d, $textofitem) EndIf $number = "" Next EndSwitch WEnd
  6. I am the Domain admin. Thats whats driving me crazy why can't I shut it down with ther permissions I have and Copy them to the location.. Very frustrating.
  7. I have run into a strange problem maybe its the sleepless nights that are clouding my mind.. Starting and Shutting down Hyper-V VM's - Need Local Administrator Rights but if I use those I can't file copy the shutdown vm to a remote location as it doesn't have permissions.. I'm guessing.. I did think that I could allow everyone to read / write etc. but that isn't good practice and I can't add the local admin to the remote pc ?? Can I add permissions to filecopy or somethign like that ? Any other Ideas are accepted as well
  8. Hello everyone Just wondering if anyone has ventured into Backing up Hyper-V Vm machines. I'm wanting to shutdown the VM.. Check its status via Ping or a response from the Hyper-V manager that its fully off and then do a copy to a network drive. Finish the copy and start the machine back up.. Now the status, Shutdown and Startup is my main challenge. Any susgesstions ?? Trying to keep it as simple as possible. I will add some loggin , email functionality etc.. Dim $WMIService Dim $VMList Dim $VMGuid Dim $ShutdownList Dim $Result $VMName = "VM2011" _ShutdownVM($VMName) Func _ShutdownVM($VMName) $WMIService = ObjGet("winmgmts:\\.\root\virtualization") $VMList = $WMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" & $VMName & "'") $VMGuid = $VMList.ItemIndex(0).Name MsgBox(0, "VM GUID", $VMGuid) $ShutdownList = $WMIService.ExecQuery("SELECT * FROM Msvm_ShutdownComponent WHERE SystemName='" & $VMGuid & "'") $Result = $ShutdownList.ItemIndex(0).InitiateShutdown(True, "Because I said so") EndFunc ;==>_ShutdownVM Func _StartupVM($VMName) $WMIService = ObjGet("winmgmts:\\.\root\virtualization") $VMList = $WMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" & $VMName & "'") ; Request a state change on the first VM that is returned' 2 = start, 3 = stop and 32769 = save state $VMList.ItemIndex(0).RequestStateChange(2) EndFunc ;==>_StartupVM
  9. I am the Network Admin
  10. I'm trying to get results as fast and accurate as possibe. Currentley pinging one pc at a time and retrieving info is great but if I could ping 1000 pcs in like 10seconds then we got some good lovin. I know Autoit Doesn't do MultiTreading but there has got to be a way around this fact.. Always lots a ways to shave a cat..
  11. Well HOLLY ....... ....... that worked.... I tried a msgbox , I tried a inputbox .. it looked perfect never showed a thing.. Finally someone thinking way outside the box.. Thank you Thank you..
  12. When I'm trying to ping a device in my script I keep getting a error code #4 from ping. Even though in dos it pings fine.. What would make the ping in the script stop working.. If I start a tottally new script it works fine.. Func _RA2011_UpdatedRecords() _dbOpen() $Recordset.Open("Needtoupdate", $Connection) With $Recordset While Not .EOF $device = .Fields("Device").Value $var = Ping($device, 1500) If $var Then; also possible: If @error = 0 Then ... MsgBox(0, "Status", "Online, roundtrip was:" & $var) Else MsgBox(0, "Status", "An error occured with number: " & @error) EndIf MsgBox(0, "info", "Device: " & $device & " IP: " & $IP & " Ping: " & $var) _update_devices($Founddomain, $device, $Ping) If WinActive("RA2012 'Remotely Assited'", "") Then GUICtrlSetData($Edit, "Activity found on pc. Stopping update." & @CRLF, 1) ExitLoop EndIf .MoveNext WEnd EndWith EndFunc ;==>_RA2011_UpdatedRecords This is so freaking simple what in Autoit would cause it to stop. If I use the $device that comes back from a query it returns the device name perfect and sets it as $device which works. But if I use that in the PING line it doesn't... If I don't use the $device at all or any other variable in there and just type it in like "pc001" then ping works again ???? WTF? HELP PLEASE!!!
  13. MsgBox(0,"info", "Device: " & $device) <-- I get the device name here no problem $var = Ping($device,250) If $var Then; also possible: If @error = 0 Then ... Msgbox(0,"Status","Online, roundtrip was:" & $var) Else Msgbox(0,"Status","An error occured with number: " & @error) <--- This message box shows up with a error code 4 even though if I ping it external from autoit it pings no problem.. EndIf PLEASE add this to the bug listing... I changed the $device to just the device name cac713094x and it responded correctley ???? ANYONE ?? SOMEONE ?? HELLO ?? HELp!
  14. whats the ping include ? This has got to be a issue with autoit directley ... where are some MVP's that can figure this one out..
  15. The bigger question is why would a simple $ping = Ping($device,500) not work and a $ping = Ping("pc001",500) work no problem..
  16. OK this is tottally screwed.. I got it working by doing this $Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 PC001 | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD) That worked .. but the just $device doesn't.. even though right before it I did a msgbox(0,"",$device) and it showed the device name no problem.. $Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 " & $Device & " | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD)
  17. I wish you could see what autoit is putting in the dos window.. before it closes...then I can debug or somethign whats going on ..
  18. Win 7 x64 Ent.
  19. It returns the results of the dos output like you just typed ping and pushed enter.
  20. In a test script the code below runs fine.. Same with the Autoit Script ping. Inside the script when this is run it comes back like the ping is in the wrong syntax.. Any idea what could be effecting both pings inside my script... $device = "PC001" $Reply = "" $Testping = Run(@ComSpec & " /c " & 'ping.exe ' & $device & " -n 1 -w 500 " & '| find "Reply" ', @WindowsDir, @SW_SHOW, $STDOUT_CHILD) While ProcessExists($Testping) Sleep(10) $Reply &= StdoutRead($Testping) If @error Then ExitLoop WEnd $ReplySplit = StringSplit($Reply, " ") If $ReplySplit >= 6 Then $IP = StringTrimRight($ReplySplit[3], 1) $Ping = StringTrimLeft($ReplySplit[5], 5) EndIf MsgBox(0,"IP: " & $ip , "Ping: " & $ping)
  21. Well if I ping from dos at the exact same time it returns a ping..Which would make me think for that reason that it is a bug..
  22. I hate to *BUMP* things but this stops my whole script from running because I can't trust the results coming back from Autoits ping can someone help me on this one.. The strange part is this time I know its not me.. Well it could be me but I don't think so.. msgbox(0,$device,$ping) $ping = Ping($device,10000) msgbox(0,$device,$ping) Returns a $Device name and blank in the message box.. " Perfect ping has nothing in it.. " slight pause cause of the 10000 timeout just for testing Returns a $Device name and 0 in the message box.. " WTF something is messed up with ping..." HELP!!!
  23. ok so this is wat I got $var = "" msgbox(0,$device, $var & " ms." & " Before." ) Result --> window with pc01 then blank ms. Before. $var = Ping($device,10000) msgbox(0,$device,$var & " ms" & " After.") Result --> window with pc01 then 0 ms. After. IS that 0 correct ? How acurate is that ping command in AutoIT ??? If I ping in dos I seem to get a steady 4ms., 5ms or 6ms. I'm trapping for Error's now and I'm getting all Error 4 's even though it says the ping returned 0 This some NEW BUG??????
  24. In one of my scripts I have $var = Ping($device, 500) msgbox(0,"PING",$var & " ms") and no matter what device I ping it gives me " 0 " even though if I ping it through dos it responds.. If I make a new script and just add $var = Ping($device, 500) msgbox(0,"PING",$var & " ms") and the device name it shows me the right response.. What would be stopping this from responding correct..
  25. Nope same issue it runs the gui on the remote system.. not locally..
×
×
  • Create New...