
noob62
Active Members-
Posts
26 -
Joined
-
Last visited
Recent Profile Visitors
72 profile views
noob62's Achievements

Seeker (1/7)
0
Reputation
-
Trying to get a script up and running that will identify if a server or workstation is being managed by either SCCM or KACE. I keep running into a issue where it always seems to default to workstation no matter what with the below script. I'm sure it's an easy fix I'm just missing something simple: Local $SCCM, $KACE, $Type, $OS $OS = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" , "ProductType") If $OS = "WinNT" Then $Type = "Workstation" ElseIf $OS = "ServerNT" Then $Type = "Server" ElseIf $OS = "LanmanNT" Then $Type = "Server" EndIf $SCCM = RegRead("HKLM64\SOFTWARE\Microsoft\SMS\Mobile Client" , "ProductVersion") $KACE = RegRead("HKLM64\SOFTWARE\Dell\Kace" , "Installld") If $Type = "Workstation" & @error = 1 Then MsgBox(4096, "INFO" , "SCCM Client: Not Installed") Elseif $Type = "Server" & @error = 1 Then MsgBox(4096, "INFO" , "KACE Client: Not Installed") Elseif $Type = "Workstation" & @error <> 1 Then MsgBox(4096, "INFO" , "SCCM Client: Installed") Elseif $Type = "Server" & @error <> 1 Then MsgBox(4096, "INFO" , "KACE Client: Installed") EndIf
-
What would be the best way to display a progress bar for comparing of the CSV files? Would i just add in a variable to increase each time and display that variable?
-
I figured out the error, there were objects that had commas in the string causing it to think there were additional fields. Thanks for all the help!
-
Added in the @error and it is showing a 3 on the CSV files that I'm trying to import and compare. I looked up the error "3 - File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set)" does that mean there are to many spaces in some of the lines or other characters that it doesn't know what to do with?
-
Getting error 0 from the FileReadToArray it even happens if I point it to the same file. I know the files are there and can see the files
-
When I run _ArrayDisplay it will only show the first Array and does not show anything for the second array. I added in a msgbox in the loop to show what is happening during the compare and it shows error -1
-
I'm trying to import two different CSV files into two arrays and find the differences in the two files where a string may exist in CSV_one column 1 but, not exist in CSV_two column 2. The problem I'm having is the script isn't loading the second CSV into the array. is there something I'm doing wrong? #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $aRetArray1 Local $aRetArray2 Local $Rows, $Find, $Result Local $i = 0 Local $sFilePath1 = "C:\Script\CSV_one.csv" Local $sFilePath2 = "C:\Script\CSV_two.csv" _FileReadToArray($sFilePath2, $aRetArray1, $FRTA_NOCOUNT, ",") $Rows = UBound($aRetArray1, $UBOUND_ROWS) _FileReadToArray($sFilePath1, $aRetArray2, $FRTA_NOCOUNT, ",") While $i < $Rows $Find = $aRetArray1[$i][0] $Result = _ArraySearch($aRetArray2, $Find) if @error = 6 Then FileWrite("C:\Script\compare.txt" , $aRetArray1[$i][0] & "," & $aRetArray1[0][$i] & @CRLF) EndIf $i = $i + 1 WEnd Also, if the CSV has multiple columns how do I write those values to a file as well since from what I understand File Read to Array will only do a 2D array.
-
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
I got it figured out now, thanks for all the help and guidance. Below is what I have that works: #include <Array.au3> Local $i = 0 Local $TotalRows, $aResult, $iCount, $aSearch Local $Limit = 4 Local $aArray[12][2] = [["Computer 1", "192.168.1.1"], _ ["Computer 2", "192.168.1.2"], _ ["Computer 1", "192.168.1.3"], _ ["Computer 3", "192.168.1.4"], _ ["Computer 3", "192.168.1.5"], _ ["Computer 1", "192.168.1.6"], _ ["Computer 1", "192.168.1.7"], _ ["Computer 4", "192.168.1.8"], _ ["Computer 5", "192.168.1.9"], _ ["Computer 6", "192.168.1.10"], _ ["Computer 7", "192.168.1.11"], _ ["Computer 1", "192.168.1.12"]] $TotalRows = UBound($aArray, $UBOUND_ROWS) ;Get total rows in the Array to search _ArraySort($aArray, 0, 0, 0, 0) ;Sort the Array While $i < $TotalRows $aSearch = $aArray[$i][0] ;Get string to search for $aResult = _ArrayFindAll($aArray, $aSearch) ; lines where $aSearch string appears in the array $iCount = UBound($aResult) ; <- total number of occurences Local $r = 0 If $Limit > $iCount Then ;If occurances are less then the specified limit While $r < $iCount ConsoleWrite($aArray[$aResult[$r]][0] & ", " & $aArray[$aResult[$r]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd Else ;If the number of occurances are greater then the specified limit While $r < $Limit ConsoleWrite($aArray[$aResult[$r]][0] & ", " & $aArray[$aResult[$r]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd EndIf $i = $i + $iCount WEnd -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
I got it to work with out picking duplicates and go through the whole Array, let me know what you think: #include <Array.au3> Local $i = 0 Local $TotalRows, $aResult, $iCount, $aSearch Local $aArray[12][2] = [["Computer 1", "192.168.1.1"], _ ["Computer 2", "192.168.1.2"], _ ["Computer 1", "192.168.1.3"], _ ["Computer 3", "192.168.1.4"], _ ["Computer 3", "192.168.1.5"], _ ["Computer 1", "192.168.1.6"], _ ["Computer 1", "192.168.1.7"], _ ["Computer 4", "192.168.1.8"], _ ["Computer 5", "192.168.1.9"], _ ["Computer 6", "192.168.1.10"], _ ["Computer 7", "192.168.1.11"], _ ["Computer 1", "192.168.1.12"]] $TotalRows = UBound($aArray, $UBOUND_ROWS) ;Get total rows in the Array to search _ArraySort($aArray, 0, 0, 0, 0) ;Sort the Array While $i < $TotalRows $aSearch = $aArray[$i][0] ;Get string to search for $aResult = _ArrayFindAll($aArray, $aSearch) ; lines where $aSearch string appears in the array $iCount = UBound($aResult) ; <- total number of occurences Local $r = 0 While $r < $iCount ConsoleWrite($aArray[$aResult[$r]][0] & ", " & $aArray[$aResult[$r]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd $i = $i + $iCount WEnd ; lines where Items where Found in the original array _ArrayDisplay($aResult, "lines where Items where Found in the original array") Now just looking at how to limit the output to a speciific number. I nested some If and While statements in there but I can't get it to work properly any ideas: #include <Array.au3> Local $i = 0 Local $TotalRows, $aResult, $iCount, $aSearch Local $Limit = 4 Local $aArray[12][2] = [["Computer 1", "192.168.1.1"], _ ["Computer 2", "192.168.1.2"], _ ["Computer 1", "192.168.1.3"], _ ["Computer 3", "192.168.1.4"], _ ["Computer 3", "192.168.1.5"], _ ["Computer 1", "192.168.1.6"], _ ["Computer 1", "192.168.1.7"], _ ["Computer 4", "192.168.1.8"], _ ["Computer 5", "192.168.1.9"], _ ["Computer 6", "192.168.1.10"], _ ["Computer 7", "192.168.1.11"], _ ["Computer 1", "192.168.1.12"]] $TotalRows = UBound($aArray, $UBOUND_ROWS) ;Get total rows in the Array to search _ArraySort($aArray, 0, 0, 0, 0) ;Sort the Array While $i < $TotalRows $aSearch = $aArray[$i][0] ;Get string to search for $aResult = _ArrayFindAll($aArray, $aSearch) ; lines where $aSearch string appears in the array $iCount = UBound($aResult) ; <- total number of occurences Local $r = 0 If $Limit > $iCount Then While $r < $iCount ConsoleWrite($aArray[$aResult[$r]][0] & ", " & $aArray[$aResult[$r]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd ElseIf $Limit < $iCount Then While $r < $iCount & $r <> $Limit ConsoleWrite($aArray[$aResult[$r]][0] & ", " & $aArray[$aResult[$r]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd EndIf $i = $i + $iCount WEnd -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
Thanks for the reply on a workaround but i'm trying to do the following: Get the first 4 occurrences of a each string in column 1 in the array and write those to a file but, have a way to work through if there is only one instance or two of a string write those to the file since they are less than 4 and avoid searching for items that have already been searched. the previous post #5 is what I think I have to work with since UniqueArray isn't working so it would be: Sort the ArrayGet the first stringget total count of string in arraywrite the first fouri + total count for the string which would go to the next string avoiding looking for duplicates -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
Hmm interesting... Any suggestions on how to achieve what I'm looking to do without UniqueArray? Would sorting the Array and searching that way still be the best approach? -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
I'm am running the latest version of AutoIt, I just uninstalled AutoIt from my system and re-downloaded and installed it. It looks like the error is occurring in the actual function: C:\Program Files (x86)\AutoIt3\Include\Array.au3" (2297) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If IsInt($aArray[$iBase]) Then If IsInt(^ ERROR That's with the example 2 for UniquArray -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
I didn't know about _ArrayUnique that's a much better way then the way I was going about it. I do get an error when I try to run the script with _ArrayUnique "Array variable has incorrect number of subscripts or subscript dimension range exceeded." Is there a limit on the size of the array that function can handle? I'm actually getting the same error when I run the second example for _ArrayUnique #include <Array.au3> Local $aArray[6][2] = [[1, "A"], [2, "B"], [3, "C"], [1, "A"], [2, "B"], [3, "C"]] _ArrayDisplay($aArray, "2D array") ; Display the current array. Local $aArrayUnique = _ArrayUnique($aArray) ; Use default parameters to create a unique array of the first column. _ArrayDisplay($aArrayUnique, "$aArray first column") ; Display the unique array. $aArrayUnique = _ArrayUnique($aArray, 1) ; Create a unique array of the second column. _ArrayDisplay($aArrayUnique, "$aArray second column") ; Display the unique array. -
Get number of occurrences in Array
noob62 replied to noob62's topic in AutoIt General Help and Support
Thanks for the replies that helped get me on the right track. Just adding in some other things like parsing through the whole array and showing the first four occurrences for each string in the first column then only displaying the first four instances of those occurrences. The question I have would nested IF statements be the right way to go to make sure it only gets the first four and what if there are less than 4 occurrences or greater than 4. This is what I have now but it gets stuck on the first string and only writes that out instead of the other ones. It seems like the correct way to me I'm just not connecting the dots somewhere. I added in a sort of the array with the idea that since its sorted and it is grabbing the total occurrences of each string it would just use the total found to move onto the next string avoiding looking at duplicate entries #include <Array.au3> Local $i = 0 Local $r = 0 Local $TotalRows, $aResult, $iCount, $aSearch Local $aArray[12][2] = [["Computer 1", "192.168.1.1"], _ ["Computer 2", "192.168.1.2"], _ ["Computer 1", "192.168.1.3"], _ ["Computer 3", "192.168.1.4"], _ ["Computer 3", "192.168.1.5"], _ ["Computer 1", "192.168.1.6"], _ ["Computer 1", "192.168.1.7"], _ ["Computer 4", "192.168.1.8"], _ ["Computer 5", "192.168.1.9"], _ ["Computer 6", "192.168.1.10"], _ ["Computer 7", "192.168.1.11"], _ ["Computer 1", "192.168.1.12"]] $TotalRows = UBound($aArray, $UBOUND_ROWS) ;Get total rows in the Array to search _ArraySort($aArray, 0, 0, 0, 0) ;Sort the Array While $i < $TotalRows $aSearch = $aArray[$i][0] ;Get string to search for $aResult = _ArrayFindAll($aArray, $aSearch) ; lines where $aSearch string appears in the array $iCount = UBound($aResult) ; <- total number of occurences While $r < $iCount ConsoleWrite($aArray[$aResult[$i]][0] & ", " & $aArray[$aResult[$i]][1] & @CRLF) ; <--< use indexes in $aResult[$i] to point to lines in original array $r = $r + 1 WEnd $i = $i + $iCount WEnd ; lines where Items where Found in the original array _ArrayDisplay($aResult, "lines where Items where Found in the original array") -
This is probably an easy solution I'm just making it complicated. Looking for some guidance on being able to search for the number of occurrences of a string in a column of an array then write the each of the occurrences and rows for that that string to a text file. Example looking for how many times Computer 1 occurs in the first column and write only the first four occurrences to the text file. Here is what I have started with: #include <Array.au3> Local $i = 0 Local $row Local $aArray[12][2] = [["Computer 1", "192.168.1.1"], _ ["Computer 2", "192.168.1.2"], _ ["Computer 1", "192.168.1.3"], _ ["Computer 3", "192.168.1.4"], _ ["Computer 3", "192.168.1.5"], _ ["Computer 1", "192.168.1.6"], _ ["Computer 1", "192.168.1.7"], _ ["Computer 4", "192.168.1.8"], _ ["Computer 5", "192.168.1.9"], _ ["Computer 6", "192.168.1.10"], _ ["Computer 7", "192.168.1.11"], _ ["Computer 1", "192.168.1.12"]] Local $aResult = _ArrayFindAll($aArray, "Computer 1") While $i < $aResult $row = $aResult[$i] FileWrite("C:\output.txt" , $row & "," & @CRLF) $i = $i + 1 WEnd _ArrayDisplay($aResult, "Items Found")