Jump to content

need help with scanning/dumping array to text file


Recommended Posts

okay, so you guys helped me out big time with a script before, and it works, but not for a repeat performance.

so I've got this great flash application that can call my executable scripts, and it can call up and read a text file(which my script writes an array to), but it doesn't re-write the text file when I hit my re-scan button, which just runs the exact same script as the original scan. The code I'm putting in here is run word for word as the scan, and as the rescan. in fact it's the same file. just run again. The problem, is that when I click my rescan button, the script doesn't clear out the text file and re-dump the array like it's supposed to. anyone have any suggestions?

#include <array.au3>

_SetupArrays()
; File post location

#include <File.au3>
Dim $FileLocation = 'C:\Reznet Setup\scan_results.txt'
$FileOpen = FileOpen($FileLocation, 2)
FileWriteLine($FileOpen, "scan_results=")
FileClose($FileOpen)
; Function tocheck for the updates
For $n = 1 To $PostSP2Updates[0]
;_ArrayAdd($diagnose,$PostSP2Updates[0])
    If Not RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\' & $PostSP2Updates[$n], "Installed") Then
        _ArrayAdd($diagnose, " Post Service Pack-2 Updates")
        ExitLoop
    EndIf
Next

; Function to check for the files
For $n = 1 To $CheckFiles[0]
    $SplitTemp = StringSplit($CheckFiles[$n], ",")
;_ArrayAdd($diagnose,$SplitTemp[1])
    If Not FileExists($SplitTemp[1]) Then _ArrayAdd($diagnose, $SplitTemp[2])
Next


;_ArrayDisplay($diagnose, "Diagnostic Results")

; Output to file
$FileOpen = FileOpen($FileLocation, 2); Look at file open, 2 erases everything, I imagine that's what you want.
For $FileWriteCount = 1 To UBound($diagnose) - 1
    If $diagnose[$FileWriteCount] And $FileWriteCount == 1 Then FileWriteLine($FileOpen, "scan_results=" & $diagnose[$FileWriteCount])
    If $diagnose[$FileWriteCount] And $FileWriteCount > 1 Then FileWriteLine($FileOpen, $diagnose[$FileWriteCount])
Next
FileClose($FileOpen); Close the FileOpen handle

; -------------------------------------------------------------------
;    Local Functions
; -------------------------------------------------------------------
; Setup Arrays Function
Func _SetupArrays()
; Array of diagnostic results
    Global $diagnose[1] = [0]
    
; Array of Post-SP2 Update reg keys to check
    Global $PostSP2Updates[1]
    _ArrayAdd($PostSP2Updates, 'KB873333')
    _ArrayAdd($PostSP2Updates, 'KB885250')
    _ArrayAdd($PostSP2Updates, 'KB886185')
    _ArrayAdd($PostSP2Updates, 'KB888113')
    _ArrayAdd($PostSP2Updates, 'KB891781')
    _ArrayAdd($PostSP2Updates, 'KB893066')
    _ArrayAdd($PostSP2Updates, 'KB896358')
    _ArrayAdd($PostSP2Updates, 'KB896422')
    _ArrayAdd($PostSP2Updates, 'KB896423')
    _ArrayAdd($PostSP2Updates, 'KB896424')
    _ArrayAdd($PostSP2Updates, 'KB896688')
    _ArrayAdd($PostSP2Updates, 'KB896727')
    _ArrayAdd($PostSP2Updates, 'KB899588')
    _ArrayAdd($PostSP2Updates, 'KB899589')
    _ArrayAdd($PostSP2Updates, 'KB900725')
    _ArrayAdd($PostSP2Updates, 'KB901017')
    _ArrayAdd($PostSP2Updates, 'KB901214')
    _ArrayAdd($PostSP2Updates, 'KB902400')
    _ArrayAdd($PostSP2Updates, 'KB904706')
    _ArrayAdd($PostSP2Updates, 'KB905414')
    _ArrayAdd($PostSP2Updates, 'KB905749')
    _ArrayAdd($PostSP2Updates, 'KB905749')
    _ArrayAdd($PostSP2Updates, 'KB905915')
    _ArrayAdd($PostSP2Updates, 'KB910437')
    _ArrayAdd($PostSP2Updates, 'KB912919')
    _ArrayAdd($PostSP2Updates, 'KB908519')
    _ArrayAdd($PostSP2Updates, 'KB901190')
    _ArrayAdd($PostSP2Updates, 'KB911927')
    _ArrayAdd($PostSP2Updates, 'KB913446')
    _ArrayAdd($PostSP2Updates, 'KB912812')
    _ArrayAdd($PostSP2Updates, 'KB908531')
    _ArrayAdd($PostSP2Updates, 'KB911562')
    $PostSP2Updates[0] = UBound($PostSP2Updates) - 1
    
; Array of files to check for existence, and associated update (comma delimited)
    Global $CheckFiles[1]
    _ArrayAdd($CheckFiles, 'C:\WINDOWS\Driver Cache\i386\sp2.cab, WindowsXP Service Pack2')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Cisco Systems\Clean Access Agent\CCAAgent.exe, Cisco Clean Access Agent')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Symantec AntiVirus\VPTray.exe, Norton Anti-Virus')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Mozilla Firefox\firefox.exe, Mozilla Firefox')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Spybot - Search & Destroy\SpybotSD.exe, Spy-Bot Search and Destroy')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Lavasoft\Ad-Aware SE Personal\Ad-Aware.exe, Ad-Aware SE Personal')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Adobe\Acrobat 7.0\Reader, Adobe Acrobat Reader 7.0')
    _ArrayAdd($CheckFiles, 'C:\Program Files\Trillian\trillian.exe, Trillian Instant Messenger')
    $CheckFiles[0] = UBound($CheckFiles) - 1
    
; Temp array of string splits
    Global $SplitTemp[1]
EndFunc ;==>_SetupArrays

"I wish I could say something that was classy and inspirational, but that just wouldn't be our style. Pain heals. Chicks dig scars. Glory lasts forever." - Shane Falco, The Replacements

Link to comment
Share on other sites

I'm having trouble understanding what you want. Do you want the text file completely erased when you rescan and then the information from the new scan put into the old text file?

If this is the case then just do a FileDelete of the old file and it will be gone, then when it is created again during the scan, it will only have the new info in it.

Nomad :D

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...