Jump to content

Array Question


Recommended Posts

Current code....not all of it mind you

$x = 1 to $FileList[0]
     $t = FileGetTime("\\" & $Wname & "\C$\Documents And Settings\" & $FileList[$x], 0)
     $varTimeStamp = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]

     $varTimeDifference = _DateDiff ("D", $varTimeStamp, _NowCalc())
     MsgBox (0, "Time Difference", "It's been " & $varTimeDifference & ' days since the profile "' & $FileList[$x] & '" was last accessed.')

        If $FileList[$x] = 'Administrator' Then
            Sleep(100)
        ElseIf $FileList[$x] = 'localservice' Then
            Sleep(100)
        ElseIf $FileList[$x] = 'networkservice' Then
            Sleep(100)

When the script cycles through the array and get it gets to the point of the Administrator, if i added the line, _ArrayDelete($FileList, $x) it would remove the entry from the array correct?

Link to comment
Share on other sites

If you loop through an array while removing entries it is best to do it from the end to the beginning:

For $x = $FileList[0] to 1 Step -1
    ; Here goes your code
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

woo! that worked perfectly!

Now, on to a second issue with arrays and strings..

With the above code it go through and checks for the administrator account and local service and then removes those from the array.

However we have admin accounts that are needing to be ignored and removed from the array as well. Only thing is that i dont want to enter in ALL the account names.

But we do have an easy way to determine which are admin and which arent. Our admin accounts have an extra set to chars at the end of the user names. so for example (imanadmin-adm)

How would i get the code to see the -adm and then remove that entire entry out of the array?

would i use stringinstr? or something else?

Link to comment
Share on other sites

ok might need to be more clear. sorry if it was confusing

Above code

If $FileList[$x] = 'Administrator' Then
            _ArrayDelete($FileList, $x)
            Sleep(100)
        ElseIf $FileList[$x] = 'localservice' Then
            Sleep(100)
        ElseIf $FileList[$x] = 'networkservice' Then
            Sleep(100)

What i would like to see is this.

If $FileList[$x] = 'user123-adm' then
            _ArrayDelete($FileList, $x)
            Sleep(100)

But the issue I am running into is that user123 changes between the different administrative accounts. The only constant that will determine the admin account vs the non-admin account is the -adm.

so how would i find the 5, 10, 15, or 50 admin accounts that have -adm on the tail end of them and remove that string from the array? without having to hard code every -adm account name int othe program?

user123-adm

123user-adm

1234567-adm

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...