Jump to content
Sign in to follow this  
gcue

"subscipt used with non-array variable"

Recommended Posts

Im trying to pull in the timestamp for NTUSDER.DAT on some remote machines.

I was able to ull the dates just fine.. but then when i added the extra one at the end i get the error: "subscript used with non-array variable"

any ideas?

thanks

$mdate = FileGetTime("\\" & $assets[$x] & "\c$\documents and settings\" & $user & "\ntuser.dat", 0, 1)
$cdate = FileGetTime("\\" & $assets[$x] & "\c$\documents and settings\" & $user & "\ntuser.dat", 1, 1)

If @error Then
ContinueLoop
EndIf

Share this post


Link to post
Share on other sites

sorry.. always try to make it for an easier read

Opt("GUIOnEventMode", 1)
#Include <GuiConstants.au3>
#Include <Constants.au3>
#include <file.au3>

$toolsdir="C:\CRS\Tools"

If Not FileExists($toolsdir) Then
    DirCreate($toolsdir)
EndIf

If Not FileExists($toolsdir & "\Security Guard") Then
    DirCreate($toolsdir & "\Security Guard")
EndIf

GUICreate("Security Guard v0.1", 290,80); WS_EX_ACCEPTFILES

$filemenu = GUICtrlCreateMenu ("&File")
$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)
GUICtrlSetOnEvent(-1,"Security_Check")
$fileexititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")
$changeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
GUICtrlSetOnEvent(-1,"Change")
$helpitem = GUICtrlCreateMenuitem ("About",$helpmenu)
GUICtrlSetOnEvent(-1,"About")

$btn = GUICtrlCreateButton ("Choose Asset File", 85,10,120,30,0x0300)
GUICtrlSetOnEvent($btn, "Security_Check")

GUICtrlSetState(-1, $GUI_FOCUS)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState(@SW_SHOW)

While 1
sleep(1000)
Wend

Func Security_Check()

$file = $toolsdir & "\Security Guard\Check.csv"

If FileExists($file) Then
    FileDelete ($file)
EndIf

FileWrite($file, "Asset, Account, NTUSER.DAT Modified, NTUSER.DAT Created")

$message = "Please choose your assets text file."

$afile = FileOpenDialog($message, @DesktopDir & "\", "Text Files (*.txt)", 1 + 4 )

If @error Then
    MsgBox(262144,"Security Guard","No file was chosen")
    Return
EndIf

Dim $assets
If Not _FileReadToArray($afile,$assets) Then
 Exit
EndIf

For $x = 1 to $assets[0]
$errorcount = 0
$status="1"
$user="1"

Ping($assets[$x])
If @error Then
$status="OFFLINE"
$user="???"
$errorcount =+1
EndIf

If $errorcount = 0 Then
RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" )
If @error Then
$status="NO_ADMIN_RIGHTS"
$user="???"
$errorcount =+1
EndIf
EndIf

If $errorcount = 0 Then
For $i= 1 to 20
    $key = RegEnumKey( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\eXpress\Inventory\SIDCache", $i)
    
    $user = RegRead( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\eXpress\Inventory\SIDCache\" & $key, "Name")
    
    If @error <> 0 then ExitLoop
    
    If $user <> "SYSTEM" AND $user <> "LOCAL SERVICE" AND $user <> "NETWORK SERVICE" AND $user <> "Administrator" AND $user <> "Administrators" Then

    $mdate = FileGetTime("\\" & $assets[$x] & "\c$\documents and settings\" & $user & "\ntuser.dat", 0, 1)
    $cdate = FileGetTime("\\" & $assets[$x] & "\c$\documents and settings\" & $user & "\ntuser.dat", 1, 1)

If @error Then
ContinueLoop
EndIf


    FileWrite($file,  '' &@CRLF & _
                      $assets[$x] & "," & $user & "," & $mdate[1] & "/" & $mdate[2] & "/" & $mdate[0] & "," & $cdate[1] & "/" & $cdate[2] & "/" & $cdate[0])
    EndIf
Next
EndIF
Next

ShellExecute($file)
EndFunc ;Security_Check

Func Change()
MsgBox(262144, "Security Guard v0.1", 'Change Log'&@CRLF & _
                        ''&@CRLF & _
                        'No Changes'&@CRLF & _
                        ''&@CRLF & _
                        'Please contact GXM x90760 for suggestions or bug reports.')
EndFunc ;Change

Func About()
MsgBox(64, "About", 'Security Guard v0.1'&@CRLF & _
                        ''&@CRLF & _
                        'Choose a text file with assets to do any of the following:'&@CRLF & _
                        ''&@CRLF & _
                        'Checks for previously logged users and shows the created/modified dates'&@CRLF & _
                        'for NTUSER.DAT from each of the users existing windows profiles.'&@CRLF & _
                        ''&@CRLF & _
                        'Contact GXM x90760 for questions/suggestions.')
EndFunc ;About


Func Xbutton()
  Exit
EndFunc ;Xbutton

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...