Neoborn Posted March 29, 2006 Share Posted March 29, 2006 (edited) Hello Guys, I am having several issues with this code below: 1. I am currently using the most recent beta JSYK 2. This code has an issue with teh $avArray[$i] for some reason in the zip part. 3. Also Whenever I try to delete the files after I zip them with a simple FileDelete command it wont work in this script but if I just copy the FileDelet to another script and run it on it's own it does delete the text files I can't figure out why. 4. Also I wonder when I am supposed to put the Func name and in what order are the various things run? Are they run sequentially i.e. top to bottom? I wonder this because some parts of this code take longer than others and also for future knowledge on where to place certain functions etc. 5. I am new to this and am learning all the time ( yes I RTFM for hours on end, and yes I try and try and try...) expandcollapse popup;------------------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------------------ #include <Array.au3> #include <file.au3> #include <Process.au3> #NoTrayIcon ;------------------------------------------------------------------------------------------ ; Array For All The Text Files ;------------------------------------------------------------------------------------------ ; Array for the file-names Dim $avArray[9] $avArray[1] = "C:\temp\" & 'AutoStart.txt' $avArray[2] = "C:\temp\" & 'Environment.txt' $avArray[3] = "C:\temp\" & 'File_Associations.txt' $avArray[4] = "C:\temp\" & 'Hardware_Info.txt' $avArray[5] = "C:\temp\" & 'Process_List.txt' $avArray[6] = "C:\temp\" & 'Program_Files.txt' $avArray[7] = "C:\temp\" & 'System_Info.txt' $avArray[8] = "C:\temp\" & 'Windows.txt' ;------------------------------------------------------------------------------------------ ; Function Calls ;------------------------------------------------------------------------------------------ autostart() environment() fileassociation() tasklist() systeminfo() windows() hwinfo() ziptxt() ;------------------------------------------------------------------------------------------ ; Beginning Of Program ( Get Program Files ) ;------------------------------------------------------------------------------------------ $search1 = FileFindFirstFile(@ProgramFilesDir & "\*.*") If $search1 = -1 Then Exit EndIf $tmpdir = ($avArray[6]) If $tmpdir = 0 Then FileDelete($avArray[6]) FileWriteLine($avArray[6], "Program Files Contents") FileWriteLine($avArray[6], "***********************") FileWriteLine($avArray[6], @CRLF) While 1 $file = FileFindNextFile($search1) If @error Then ExitLoop If Not StringInStr($file, ".") Then FileWriteLine($avArray[6], $file & @CRLF) EndIf WEnd ; Close the search handle FileClose($search1) $tmptotal = 0 $drives = DriveGetDrive("fixed") If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & "\") = "READY" Then If FileExists($drives[$i] & "\Documents And Settings\") Then $users = FileFindFirstFile($drives[$i] & "\Documents And Settings\*.*") If $users <> - 1 Then While 1 $cuser = FileFindNextFile($users) If @error Then ExitLoop If $cuser = "All Users" Or $cuser = "Default User" Or $cuser = "LocalService" Or $cuser = "NetworkService" Or $cuser = "." Or $cuser = ".." Then ContinueLoop delcont($drives[$i] & "\Documents And Settings\" & $cuser & "\Local Settings\Temp", "", 0) delcont($drives[$i] & "\Documents And Settings\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0) WEnd EndIf FileClose($users) EndIf delcont($drives[$i] & "\Windows\Temp", "", 0) delcont($drives[$i] & "\Windows\Temporary Internet Files\Content.IE5", ".txt", 0) EndIf Next EndIf Func delcont($folder, $filespec, $dlfldr) If Not FileExists($folder) Then Return If StringInStr(FileGetAttrib($folder), "D") Then $cur = FileFindFirstFile($folder & "\*") While 1 $curfile = FileFindNextFile($cur) If @error Then ExitLoop If $curfile = "." Or $curfile = ".." Then ContinueLoop If StringInStr(FileGetAttrib($folder & "\" & $curfile), "D") Then delcont($folder & "\" & $curfile, $filespec, 1) Else If $filespec = "" Then mydel($folder & "\" & $curfile) Else If Not StringInStr($curfile, $filespec) Then mydel($folder & "\" & $curfile) EndIf EndIf EndIf WEnd FileClose($cur) If $dlfldr = 1 Then rmifempty($folder) EndIf EndFunc ;==>delcont Func mydel($fl) If StringInStr(FileGetAttrib($fl), "R") Then FileSetAttrib($fl, "-R") $tst = FileDelete($fl) If $tst <> 0 Then $tmptotal = $tmptotal + 1 ToolTip("Files Deleted: " & $tmptotal); & @LF & "Current File: " & $fl EndFunc ;==>mydel Func rmifempty($fl) $fld = FileFindFirstFile($fl & "\*") While 1 $fldr = FileFindNextFile($fld) If @error Then ExitLoop If $fldr = "." Or $fldr = ".." Then ContinueLoop Return WEnd FileClose($fld) DirRemove($fl) EndFunc ;==>rmifempty ;------------------------------------------------------------------------------------------ ; Delete Cookies in %UserProfile% ;------------------------------------------------------------------------------------------ $TempCdelete = FileDelete(@UserProfileDir & "\Cookies\*.txt") ;------------------------------------------------------------------------------------------ ; Delete Temporary Internet Files in %UserProfile% ;------------------------------------------------------------------------------------------ _DeleteFiles(@UserProfileDir & "\Local Settings\Temporary Internet Files\", "*.*", 1) Func _DeleteFiles($sPath, $sFilter, $iRemDir = 0) Local $hSearch, $sFile $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then If $iRemDir = 1 Then DirRemove($sPath) SetError(1) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error = 1 Then If $iRemDir = 1 Then DirRemove($sPath, 0) SetError(0) Return 1 EndIf If $sFile = ".." Or $sFile = "." Then ContinueLoop $sFile = $sPath & "\" & $sFile If StringInStr(FileGetAttrib($sFile), "D") Then _DeleteFiles($sFile, "*", 1) ContinueLoop EndIf FileDelete($sFile) WEnd EndFunc ;==>_DeleteFiles ;------------------------------------------------------------------------------------------ ; Processes below set various registry entries for Internet Explorer Settings ; such as setting temp internet file space size, opening IE in fullscreen etc ;------------------------------------------------------------------------------------------ RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "FullScreen", "REG_SZ", "yes") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "Delete_Temp_Files_On_Exit", "REG_SZ", "yes") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "Start Page", "REG_SZ", "rsa-on.mynightingale.net") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content", "CacheLimit", "REG_DWORD", "102400") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\", "SyncMode5", "REG_DWORD", "3") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\bc", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\rsa-on", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\rsa-bc", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\www", "https", "REG_DWORD", "0x00000002") ;------------------------------------------------------------------------------------------ ; Find out valuable information such as system information, RAM, OS version, CPU etc ;------------------------------------------------------------------------------------------ DirCreate("C:\temp") Func tasklist() Run(@ComSpec & " /c " & "tasklist /v > " & $avArray[5], "", @SW_HIDE) EndFunc ;==>tasklist Func environment() Run(@ComSpec & " /c " & "set > " & $avArray[2], "", @SW_HIDE) Sleep(200) Run(@ComSpec & " /c " & "net use >> " & $avArray[2], "", @SW_HIDE) EndFunc ;==>environment Func windows() Run(@ComSpec & " /c " & "netsh diag show os /v > " & $avArray[8], "", @SW_HIDE) EndFunc ;==>windows Func systeminfo() Run(@ComSpec & " /c " & "systeminfo.exe > " & $avArray[7], "", @SW_HIDE) EndFunc ;==>systeminfo Func fileassociation() Run(@ComSpec & " /c " & "assoc > " & $avArray[3], "", @SW_HIDE) EndFunc ;==>fileassociation ; ---------------------------------------------------------------------------- ; Author: Thorsten Meger ; Script Function: Func autoStart ; ---------------------------------------------------------------------------- Func autostart() Local $Count = 1 Local Const $regkey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' While 1 $key = RegEnumVal($regkey, $Count) If @error <> 0 Then ExitLoop $line = RegRead($regkey, $key) $file1 = FileOpen($avArray[1], 1) FileWriteLine($avArray[1], $line) If $line <> '' Then If Not IsDeclared('avArray') Then Dim $avArray[3] ReDim $avArray[UBound($avArray) + 1] $avArray[0] = UBound($avArray) - 1 $avArray[UBound($avArray) - 1] = $line EndIf $Count = $Count + 1 WEnd $search2 = FileFindFirstFile(@UserProfileDir & "\Start Menu\Programs\Startup\*.*") If $search2 = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $foundFile = FileFindNextFile($search2) If @error Then ExitLoop FileWriteLine($file1, $foundFile) WEnd ; Close the search handle FileClose($search2) $search3 = FileFindFirstFile(@StartupCommonDir & "\*.*") If $search3 = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $foundFile = FileFindNextFile($search3) If @error Then ExitLoop FileWriteLine($file1, $foundFile) WEnd FileClose($search3) EndFunc ;==>autostart ; ---------------------------------------------------------------------------- ; Author: Chaos2 ; Script Function: output basic hardware info ; ---------------------------------------------------------------------------- Func hwinfo() $objWMIService = ObjGet ("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colSettings = $objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") $colMemory = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") $colCPU = $objWMIService.ExecQuery ("Select * from CIM_Processor") $colVideoinfo = $objWMIService.ExecQuery ("Select * from Win32_VideoController") $colSound = $objWMIService.ExecQuery ("Select * from Win32_SoundDevice") $colMouse = $objWMIService.ExecQuery ("Select * from Win32_PointingDevice") $colMonitor = $objWMIService.ExecQuery ("Select * from Win32_DesktopMonitor") $colNIC = $objWMIservice.ExecQuery ("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2") Dim $pcinfo For $object In $colCPU $pcinfo = $pcinfo & StringStripWS($object.Name, 1) & @CRLF Next For $objOperatingSystem In $colSettings $pcinfo = $pcinfo & $objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Servicepack " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion & @CRLF $pcinfo = $pcinfo & "Available Physical Memory : " & String(Int(Number($objOperatingSystem.FreePhysicalMemory) / 1024)) & " Mb" & @CRLF Next For $object In $colMemory $pcinfo = $pcinfo & "Total Physical Memory : " & String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " Mb" & @CRLF Next $objFSO = ObjCreate ("Scripting.FileSystemObject") $colDrives = $objFSO.Drives $Opticaldrives = "Opticaldrives : " For $object In $colDrives If ($object.DriveType == 2) Then $pcinfo = $pcinfo & "Total space on : " & $object.DriveLetter & ":\ (" & $object.VolumeName & ") = " & String(Round((Number($object.TotalSize) / (1024 * 1024 * 1024)), 2)) & " Gb" & @CRLF $pcinfo = $pcinfo & "Free space on : " & $object.DriveLetter & ":\ (" & $object.VolumeName & ") = " & String(Round((Number($object.FreeSpace) / (1024 * 1024 * 1024)), 2)) & " Gb" & @CRLF Else $Opticaldrives = $Opticaldrives & $object.DriveLetter & ":\ " EndIf Next $pcinfo = $pcinfo & $Opticaldrives & @CRLF For $object In $colVideoinfo $pcinfo = $pcinfo & "Video card : " & $object.Description & @CRLF Next For $object In $colSound $pcinfo = $pcinfo & "Sound device : " & $object.Description & @CRLF Next For $object In $colMouse $pcinfo = $pcinfo & "Mouse : " & $object.Description & @CRLF Next For $object In $colMonitor $pcinfo = $pcinfo & "Monitor : " & $object.Description & @CRLF Next For $object In $colNIC $pcinfo = $pcinfo & $object.Name & @CRLF Next FileWrite($avArray[4], "Hardware Information" & @CRLF & "********************" & @CRLF & @CRLF & $pcinfo) EndFunc ;==>hwinfo ;----------------------------------------------------------------------------- ; Author: mozart90 + Thorsten Meger ; Script Function: Easy Zip compression under Win XP ; ---------------------------------------------------------------------------- Func ziptxt() $oShell = ObjCreate ("Shell.Application") ; Create s shell Object $ZipAchive = "C:\temp\Helpdesk.zip" If IsObj ($oShell) Then initZip($ZipAchive) ; Create an emtpy zip file with header $oDir = $oShell.NameSpace ($ZipAchive) ; Use the zip file as a "Folder" For $i = 9 To 1 Step - 1 $oDir.CopyHere ($avArray[$i]) ; Copy the 10 files in the "Zip Folder" MsgBox(262144,'Debug line ~332','Selection:' & @lf & '$oDir.CopyHere ($avArray[$i])' & @lf & @lf & 'Return:' & @lf & $oDir.CopyHere ($avArray[$i]) & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX Next Sleep(15000) ; Give the Objekt a litte bit time to work Else MsgBox(0, "Error", "Error creating Object.") EndIf EndFunc ;==>ziptxt Func initZip($zip_path_name) $init_zipString = Chr(80) & Chr(75) & Chr(5) & Chr(6) ; Create the Header String For $n = 1 To 18 $init_zipString = $init_zipString & Chr(0) ; the Header Next $file2 = FileOpen($zip_path_name, 2) FileWrite($file2, $init_zipString) ; Write the string in a file FileClose($file2) EndFunc ;==>initZip ;----------------------------------------------------------------------------- ; Copy The Folder To The Desktop ;----------------------------------------------------------------------------- FileCopy("C:\temp\Helpdesk.zip", @DesktopDir & "\Helpdesk Information & Files\", 8) Thanks guys for any input. Please don't hypothesize, please test to see if it works for you. I really appreciate any help. Also would love some tips on how to troubleshoot / methods of troubleshooting. Edited March 29, 2006 by Neoborn ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
Neoborn Posted March 30, 2006 Author Share Posted March 30, 2006 Hello ? Bueller, Bueller, Bue..... ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
jpm Posted March 30, 2006 Share Posted March 30, 2006 Hello ? Bueller, Bueller, Bue.....I don't know what "Bueller" means but I can try to help you a little bit 1. it is not a good habit to intermix function and main script. I don't if you realize that your script is mainly the following expandcollapse popup;------------------------------------------------------------------------------------------ ; Array For All The Text Files ;------------------------------------------------------------------------------------------ ; Array for the file-names Dim $avArray[9] $avArray[1] = "C:\temp\" & 'AutoStart.txt' $avArray[2] = "C:\temp\" & 'Environment.txt' $avArray[3] = "C:\temp\" & 'File_Associations.txt' $avArray[4] = "C:\temp\" & 'Hardware_Info.txt' $avArray[5] = "C:\temp\" & 'Process_List.txt' $avArray[6] = "C:\temp\" & 'Program_Files.txt' $avArray[7] = "C:\temp\" & 'System_Info.txt' $avArray[8] = "C:\temp\" & 'Windows.txt' ;------------------------------------------------------------------------------------------ ; Function Calls ;------------------------------------------------------------------------------------------ autostart() environment() fileassociation() tasklist() systeminfo() windows() hwinfo() ziptxt() ;------------------------------------------------------------------------------------------ ; Beginning Of Program ( Get Program Files ) ;------------------------------------------------------------------------------------------ $search1 = FileFindFirstFile(@ProgramFilesDir & "\*.*") If $search1 = -1 Then Exit EndIf $tmpdir = ($avArray[6]) If $tmpdir = 0 Then FileDelete($avArray[6]) FileWriteLine($avArray[6], "Program Files Contents") FileWriteLine($avArray[6], "***********************") FileWriteLine($avArray[6], @CRLF) While 1 $file = FileFindNextFile($search1) If @error Then ExitLoop If Not StringInStr($file, ".") Then FileWriteLine($avArray[6], $file & @CRLF) EndIf WEnd ; Close the search handle FileClose($search1) $tmptotal = 0 $drives = DriveGetDrive("fixed") If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & "\") = "READY" Then If FileExists($drives[$i] & "\Documents And Settings\") Then $users = FileFindFirstFile($drives[$i] & "\Documents And Settings\*.*") If $users <> - 1 Then While 1 $cuser = FileFindNextFile($users) If @error Then ExitLoop If $cuser = "All Users" Or $cuser = "Default User" Or $cuser = "LocalService" Or $cuser = "NetworkService" Or $cuser = "." Or $cuser = ".." Then ContinueLoop delcont($drives[$i] & "\Documents And Settings\" & $cuser & "\Local Settings\Temp", "", 0) delcont($drives[$i] & "\Documents And Settings\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0) WEnd EndIf FileClose($users) EndIf delcont($drives[$i] & "\Windows\Temp", "", 0) delcont($drives[$i] & "\Windows\Temporary Internet Files\Content.IE5", ".txt", 0) EndIf Next EndIf ;------------------------------------------------------------------------------------------ ; Delete Cookies in %UserProfile% ;------------------------------------------------------------------------------------------ $TempCdelete = FileDelete(@UserProfileDir & "\Cookies\*.txt") ;------------------------------------------------------------------------------------------ ; Delete Temporary Internet Files in %UserProfile% ;------------------------------------------------------------------------------------------ _DeleteFiles(@UserProfileDir & "\Local Settings\Temporary Internet Files\", "*.*", 1) ;------------------------------------------------------------------------------------------ ; Processes below set various registry entries for Internet Explorer Settings ; such as setting temp internet file space size, opening IE in fullscreen etc ;------------------------------------------------------------------------------------------ RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "FullScreen", "REG_SZ", "yes") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "Delete_Temp_Files_On_Exit", "REG_SZ", "yes") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\", "Start Page", "REG_SZ", "rsa-on.mynightingale.net") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content", "CacheLimit", "REG_DWORD", "102400") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\", "SyncMode5", "REG_DWORD", "3") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\bc", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\rsa-on", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\rsa-bc", "https", "REG_DWORD", "0x00000002") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\mynightingale.net\www", "https", "REG_DWORD", "0x00000002") ;------------------------------------------------------------------------------------------ ; Find out valuable information such as system information, RAM, OS version, CPU etc ;------------------------------------------------------------------------------------------ DirCreate("C:\temp") ;----------------------------------------------------------------------------- ; Copy The Folder To The Desktop ;----------------------------------------------------------------------------- FileCopy("C:\temp\Helpdesk.zip", @DesktopDir & "\Helpdesk Information & Files\", 8) Followed by the functions declaration that will be used when called. I think now you can reorganize the logic of your script to execute in the right order. Good luck Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now