Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/2016 in all areas

  1. [BUGFIX VERSION] - 6 Apr 24 Fixed: UDF failed if header colours were initialised but not specifically set. New UDF in the zip below. -------------------------------------------------------------------------------------- Note: This is a new recoded and expanded version of my earlier UDF of the same name. If you move to this new version there might well be several script-breaking changes, particularly when setting which columns are to be editable. Please read the "Beginner's Guide" and look at the included example scripts to see where things have changed. -------------------------------------------------------------------------------------- This UDF allows you to do much more with ListView controls (either native or UDF created): Edit the content with plain text, combos or date-time pickers - and edit the headers too Move rows within the ListView Drag rows both within the ListView and to other ListViews in the same GUI (or not as required) Insert and delete columns and rows Sort columns by simply clicking the header Colour individual ListView items and headers Only select a single cell rather then the entire row Save and load entire ListViews For the advanced user: If you use certain Windows message handlers (In particular WM_NOTIFY) in your script, please read the function headers for the equivalent handlers within the UDF. Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip Credit to: martin (basic drag code), Array.au3 authors (array functions), KaFu and ProgAndy (font function), LarsJ (colouring code) Happy to take compliments or criticism - preferably the former! M23
    1 point
  2. water

    AD - Active Directory UDF

    Version 1.6.3.0

    17,292 downloads

    Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  3. I don't understand why my previous code does not work. Can you try this one ? #include <WinAPIFiles.au3> #include <Array.au3> Local $aDriveInfo, $iLastDevNumber = -1 Local $aFixed = DriveGetDrive('FIXED'), $aRemovable = DriveGetDrive('REMOVABLE') Local $aDrives[ (IsArray($aFixed) ? $aFixed[0] : 0) + (IsArray($aRemovable) ? $aRemovable[0] : 0) ][3] Local $iDrive = 0 For $i = 1 To UBound($aFixed) - 1 $aDrives[$iDrive][0] = $aFixed[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aFixed[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next For $i = 1 To UBound($aRemovable) - 1 $aDrives[$iDrive][0] = $aRemovable[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aRemovable[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next _ArraySort($aDrives, 0, 0, 0, 1) Local $sDrivesInfo = "Drive list :" & @CRLF For $i = 0 To UBound($aDrives) - 1 If IsNumber($aDrives[$i][1]) Then If $aDrives[$i][1] <> $iLastDevNumber Then $sDrivesInfo &= @CRLF & "Disk #" & $aDrives[$i][1] & " [" & _GetDiskNameByNumber($aDrives[$i][1]) & "]" & @CRLF $iLastDevNumber = $aDrives[$i][1] EndIf $sDrivesInfo &= " - Partition #" & $aDrives[$i][2] & " " & DriveGetLabel($aDrives[$i][0]) & " - " & $aDrives[$i][0] & @CRLF EndIf Next MsgBox(0, "", $sDrivesInfo) Func _GetDiskNameByNumber($iDiskNumber) Local $iCount = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", "Count") Local $sDiskKey = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", String($iDiskNumber)) If @error Then Return SetError(1, 0, 0) Local $sDiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $sDiskKey, "FriendlyName") If $sDiskName = "" Then $sDiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $sDiskKey, "DeviceDesc") Return $sDiskName EndFunc
    1 point
  4. I extract the .MSI from the .EXE and then run it with standard MSIEXEC silent flags. You can use a transform file to make changes to your install, or parameters, or what I do is just modify the MSI with InstaEdit
    1 point
  5. I didn't found any option to set the blur level except the background color. http://lmgtfy.com/?q=SetWindowCompositionAttribute
    1 point
  6. ? ; https://www.autoitscript.com/forum/topic/91598-get-disk-number-from-drive-letter/?do=findComment&comment=659721 ; by trancexx ; $sDDriveLetter = "C" #include <array.au3> Global $aDiskArray[1][2] $aDiskArray[0][0] = "Total disks found =" For $i = 97 To 122 $sDDriveLetter = Chr($i) $iDiskNumber = _GetDiskNimberForDrive($sDDriveLetter) If Not @error Then $aDiskArray[0][1] += 1 ReDim $aDiskArray[UBound($aDiskArray) + 1][2] $aDiskArray[UBound($aDiskArray) - 1][0] = Chr($i) $aDiskArray[UBound($aDiskArray) - 1][1] = "disk" & $iDiskNumber EndIf Next _ArrayDisplay($aDiskArray) #cs If @error Then MsgBox(48, "Error", "Error Number " & @error & @CRLF) Else MsgBox(64, "_GetDiskNimberForDrive", "Drive " & StringUpper($sDDriveLetter) & " is on disk #" & $iDiskNumber) EndIf #ce Func _GetDiskNimberForDrive($sDriveLetter) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFile", _ "str", "\\.\" & $sDriveLetter & ":", _; logical drive "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _; OPEN_EXISTING "dword", 128, _; FILE_ATTRIBUTE_NORMAL "ptr", 0) If @error Then Return SetError(1, 0, -1); your system is very old. Do something. EndIf If $a_hCall[0] = -1 Then Return SetError(2, 0, -1); non-existing drive EndIf Local $hDevice = $a_hCall[0] Local $tIOCTL_STORAGE_GET_DEVICE_NUMBER = DllStructCreate("dword DeviceType;" & _ "dword DeviceNumber;" & _ "int PartitionNumber") Local $a_iCall = DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDevice, _ "dword", 0x2D1080, _; IOCTL_STORAGE_GET_DEVICE_NUMBER "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword", DllStructGetSize($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword*", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice) Return SetError(3, 0, -1); DeviceIoControl failed for some reason EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice) ; will write some data ConsoleWrite("Drive " & StringUpper($sDriveLetter) & ": " & @CRLF) ConsoleWrite(@TAB & "DeviceType: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType") & @CRLF) ConsoleWrite(@TAB & "DeviceNumber: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber") & @CRLF) ConsoleWrite(@TAB & "PartitionNumber: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "PartitionNumber") & @CRLF) ConsoleWrite(@CRLF) ; end writing If DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType") = 7 Then; FILE_DEVICE_DISK Return SetError(0, 0, DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber")) EndIf Return SetError(4, 0, -1); not a disk partition EndFunc ;==>_GetDiskNimberForDrive
    1 point
  7. _ArrayDisplay($aDrives)
    1 point
  8. In this other recent thread there was this code by trancexx working fine for me: ; https://www.autoitscript.com/forum/topic/91598-get-disk-number-from-drive-letter/?do=findComment&comment=659721 ; by trancexx ; $sDDriveLetter = "C" For $i = 97 To 122 $sDDriveLetter = Chr($i) $iDiskNumber = _GetDiskNimberForDrive($sDDriveLetter) Next #cs If @error Then MsgBox(48, "Error", "Error Number " & @error & @CRLF) Else MsgBox(64, "_GetDiskNimberForDrive", "Drive " & StringUpper($sDDriveLetter) & " is on disk #" & $iDiskNumber) EndIf #ce Func _GetDiskNimberForDrive($sDriveLetter) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFile", _ "str", "\\.\" & $sDriveLetter & ":", _; logical drive "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _; OPEN_EXISTING "dword", 128, _; FILE_ATTRIBUTE_NORMAL "ptr", 0) If @error Then Return SetError(1, 0, -1); your system is very old. Do something. EndIf If $a_hCall[0] = -1 Then Return SetError(2, 0, -1); non-existing drive EndIf Local $hDevice = $a_hCall[0] Local $tIOCTL_STORAGE_GET_DEVICE_NUMBER = DllStructCreate("dword DeviceType;" & _ "dword DeviceNumber;" & _ "int PartitionNumber") Local $a_iCall = DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDevice, _ "dword", 0x2D1080, _; IOCTL_STORAGE_GET_DEVICE_NUMBER "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword", DllStructGetSize($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword*", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice) Return SetError(3, 0, -1); DeviceIoControl failed for some reason EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice) ; will write some data ConsoleWrite("Drive " & StringUpper($sDriveLetter) & ": " & @CRLF) ConsoleWrite(@TAB & "DeviceType: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType") & @CRLF) ConsoleWrite(@TAB & "DeviceNumber: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber") & @CRLF) ConsoleWrite(@TAB & "PartitionNumber: " & DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "PartitionNumber") & @CRLF) ConsoleWrite(@CRLF) ; end writing If DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType") = 7 Then; FILE_DEVICE_DISK Return SetError(0, 0, DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber")) EndIf Return SetError(4, 0, -1); not a disk partition EndFunc ;==>_GetDiskNimberForDrive
    1 point
  9. Can you insert an _ArrayDisplay just after the _ArraySort ? what does it show ?
    1 point
  10. can you try this one ? #include <WinAPIFiles.au3> #include <Array.au3> Local $aDriveInfo, $iLastDevNumber = -1 Local $aFixed = DriveGetDrive('FIXED'), $aRemovable = DriveGetDrive('REMOVABLE') Local $aDrives[ (IsArray($aFixed) ? $aFixed[0] : 0) + (IsArray($aRemovable) ? $aRemovable[0] : 0) ][3] Local $iDrive = 0 For $i = 1 To UBound($aFixed) - 1 $aDrives[$iDrive][0] = $aFixed[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aFixed[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next For $i = 1 To UBound($aRemovable) - 1 $aDrives[$iDrive][0] = $aRemovable[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aRemovable[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next _ArraySort($aDrives, 0, 0, 0, 1) Local $aDisks[1][2], $iDisk = 0 For $i = 0 To $iDrive - 1 If Not IsNumber($aDrives[$i][1]) Then ContinueLoop If $aDrives[$i][1] <> $iLastDevNumber Then ReDim $aDisks[$iDisk + 1][2] $aDisks[$iDisk][0] = "Disk #"& $aDrives[$i][1] & " [" & _GetDiskNameByNumber($aDrives[$i][1]) & "]" $aDisks[$iDisk][1] = $aDrives[$i][0] & " (partition #" & $aDrives[$i][2] & ")" $iDisk += 1 $iLastDevNumber = $aDrives[$i][1] Else $aDisks[$iDisk - 1][1] &= "; " & $aDrives[$i][0] & " (partition #" & $aDrives[$i][2] & ")" Endif Next _ArrayDisplay($aDisks, "Disks/paritions") Func _GetDiskNameByNumber($iDiskNumber) Local $iCount = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", "Count") Local $sDiskKey = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", String($iDiskNumber)) If @error Then Return SetError(1, 0, 0) Local $sDiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $sDiskKey, "FriendlyName") If $sDiskName = "" Then $sDiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $sDiskKey, "DeviceDesc") Return $sDiskName EndFunc
    1 point
  11. _WinAPI_EmptyWorkingSet is not a good idea. It pages data out of memory to the hard drive, which means that it will cause the programs to run slower. Memory is faster than reading/writing from a disk. There's absolutely NO reason to try to reduce virtual memory size, virtual memory is your page file on the hard drive. The only way to reduce virtual memory is to change your page file size, which limits your programs as to how much it can page to the disk. The 2 processes you're trying to accomplish are actually in exact opposition to each other, either you want the data in faster memory or you want it on the hard drive in the page file, trying to reduce both is foolish.
    1 point
  12. Very interesting.
    1 point
  13. Hi, Updated: 7 Aug 2012 Some Tool scripts to help you with your USB drive management: ChangeUSBdriveLetter: Easily change a USB drive Letter The script will pop-up the ejectable USB drives only. Double Click to select Select the new drive letter and press OK Keep in mind that the script will require elevated rights, same as Computer/Disk Management ChangeUSBdriveLetter 1.1.zip EjectUSB: Easily eject a USB drive. The script will pop-up all the ejectable USB drives. Double Click to eject The script will automatically (by default without pop-up) eject the USB drive if only one USB drive is identified on the system. This script has an optional ini file (see the Description in the header of the script, example in the zip file) This script uses wraithdu's _USB_UDF.au3 and can be found here: _USB_UDF.au3 EjectUSB 1.2.zip New: USBScanAndFix: Correct recurring Scan and fix message on USB devices When a FAT formatted "removable" USB drive is attached under Vista and Win7, the "Scan and Fix" dialog is sometimes shown each time you insert the USB device. Performing Scan and fix does not seem to resolve the issue, however, no errors are found on the device. The reason for the error is that the USB drive was formatted FAT(32) on Windows XP. When the device was not properly dismounted by Windows XP, an archive bit in the drive's boot sector is set that needs to reset before it will stop reporting that there is an error. The script will perform a checkdsk /f on the selected USB device. The script will pop-up the ejectable USB drives only as in the previous 2 scripts but will grey out the non-FAT formated devices. Please note that the script is OS language sensitive (chkdsk !) and currently only supports English and Dutch. Any help would be appreciated if you could send me your language settings (line 63 to 66) Issue: StdoutRead seems sometime to miss some console data. I am not sure why this is happening. I made the loop as tight as possible. If anyone has a suggestion, let me know... Anyhow, most of the time, the script runs correctly and it's all about cosmetics anyhow, the chkdsk is performed. USBScanAndFix 1.0.zip All scripts tested in Windows XP, Windows Vista, Windows 7, x64 Greencan
    1 point
  14. Wow thanks guys for the info. I've since added more features like multiple address emailing, changing the progress colours according to thresholds, reading some of the info from a config file and some local logging. Sorry Zedna but I hadn't seen this post until now so have coded with Spiff59's suggestions but will now take a look at what you suggest and make the changes. I'll include what I have so far before your suggestions and also some sample required files for it to work. The Gui looks relatively the same. The attached screenshot was triggered to show the progress colours and status info. #include <Constants.au3> #include <Date.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <INet.au3> Dim $aRecords, $Results, $Effective_date, $Expiry_Details, $Expiry_DetailsData, $CertUtilLogs, $FILE, $LOG Global $XS_n $Version = "CRL Endpoint Check v3.2.2" If NOT FileExists("Config.ini") then MsgBox(16, "Config File Read Error", "The configuration file Config.ini is missing or is unable to be opened." & @CRLF & @CRLF & "Make sure a file called 'config.ini' is in the same directory as this .exe file and the application has read permissions." & @CRLF & @CRLF & "Press OK to exit this application.") Exit EndIf ; Email Settings from config.ini $s_SmtpServer = IniRead("Config.ini", "MailSettings", "SMTPServer", "") $s_FromName = IniRead("Config.ini", "MailSettings", "FromName", "") $s_FromAddress = IniRead("Config.ini", "MailSettings", "FromAddress", "") $s_helo = "EHLO VANguard_CRL_Endpoint_Check" $s_first = -1 Dim $as_Body[2] ; General Settings from config.ini $CSVInput = IniRead("Config.ini", "Settings", "InputCSV", "") $LogFile = IniRead("Config.ini", "Settings", "LogFileName", "") $TimerValue = IniRead("Config.ini", "Settings", "RefreshTimeMins", "") If $TimerValue < 2 Then $TimerValue = 2 $TimerValue = $TimerValue * 60000 $WarningThreshold = IniRead("Config.ini", "Settings", "WarningThreshold", "") If $WarningThreshold < 20 then $WarningThreshold = 20 $ResolvedThreshold = $WarningThreshold If Not _FileReadToArray($CSVInput, $aRecords) Then MsgBox(16, "CSV File Read Error", "Error reading log to Array." & @CRLF & @CRLF & "Make sure a file called " & $CSVInput & " is in the same directory as this .exe file." & @CRLF & @CRLF & "Press OK to exit this application.") Exit EndIf $LOG = FileOpen($LogFile, 1) ; Check if file opened for writing OK If $LOG = -1 Then MsgBox(16, "Error", "Unable to open log file. Check permissions for read/write access to the current directory." & @CRLF & @CRLF & "Press OK to exit this application.") Exit EndIf FileWriteLine($LOG, @CRLF & _NowCalc() & " ---> " & $Version & " Application :- Started" & @CRLF) Global $s_Environment[$aRecords[0] + 1], $s_Endpoint[$aRecords[0] + 1], $s_URL[$aRecords[0] + 1], $s_ToAddress[$aRecords[0] + 1] For $x = 1 to $aRecords[0] $atemp = StringSplit($aRecords[$x], ",") $s_Environment[$x] = $atemp[1] $s_Endpoint[$x] = $atemp[2] If Not FileExists($s_Endpoint[$x]) Then DirCreate($s_Environment[$x]) $s_URL[$x] = $atemp[3] Next Global $Label_Environment[$aRecords[0] + 1], $Label_Endpoint[$aRecords[0] + 1], $Label_MinsLeft[$aRecords[0] + 1], $Progress[$aRecords[0] + 1], $Status[$aRecords[0] + 1], $StatusCount[$aRecords[0] + 1] $mainWindow = GUICreate($Version & " (Updates every " & ($TimerValue / 60000) & " Minute/s)", 700, (($aRecords[0] * 20) + 100)) Opt("TrayIconHide", 1) Opt("GUIOnEventMode", 0) XPStyleToggle(1) GUISetState() GUICtrlCreateGroup("Environment ---> EndPoint", 20, 10, 250, (($aRecords[0] * 20) + 40)) GUICtrlCreateGroup("Expiry Times Percentage", 280, 10, 280, (($aRecords[0] * 20) + 40)) GUICtrlCreateGroup("Mins before Expiry", 570, 10, 110, (($aRecords[0] * 20) + 40)) ;Create array for labels For $x = 1 to $aRecords[0] $Label_Environment[$x] = GUICtrlCreateLabel($s_Environment[$x], 30, 20 + $x * 20, 60, 17) GUICtrlCreateLabel("--->", 100, 20 + $x * 20, 30, 17) $Label_Endpoint[$x] = GUICtrlCreateLabel($s_Endpoint[$x], 120, 20 + $x * 20, 120, 17) $Progress[$x] = GUICtrlCreateProgress(290, 20 + $x * 20, 260, 17, $PBS_SMOOTH) $Label_MinsLeft[$x] = GUICtrlCreateLabel("", 580, 20 + $x * 20, 95, 17) $Status[$x] = "" $StatusCount[$x] = "" Next $LastUpdate = GUICtrlCreateLabel("Last Updated...", 30, (($aRecords[0] * 20) + 55), 200, 17) GUICtrlCreateLabel("Service Started: " & _NowCalc(), 30, (($aRecords[0] * 20) + 75), 200, 17) $RefreshProgress = GUICtrlCreateProgress(290, (($aRecords[0] * 20) + 57), 260, 17, $PBS_SMOOTH) $RefreshButton = GUICtrlCreateButton("Manual Refresh", 570, (($aRecords[0] * 20) + 57), 110, 20) GUICtrlCreateLabel("Email triggered at '" & $WarningThreshold & "'", 575, (($aRecords[0] * 20) + 80), 200, 17) GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) $SMTPLabel = GUICtrlCreateLabel("Last Email Sent about: (None triggered)", 290, (($aRecords[0] * 20) + 80), 260, 17) $line = 40 While 1 For $x = 1 to $aRecords[0] $Endpoints = StringSplit($aRecords[$x], ",") $s_ToAddress = $Endpoints[4] If Not FileExists($s_Environment[$x]) Then DirCreate($s_Environment[$x]) EndIf GUICtrlSetColor($Label_MinsLeft[$x], 0x000000) ; Black GUICtrlSetData($Label_MinsLeft[$x], "*** UPDATING ***") #Alternate Local $hDownload = InetGet($s_URL[$x], $s_Environment[$x] & "\" & $s_Endpoint[$x] & ".crl", 3, 1) Do Sleep(20) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $aData = InetGetInfo($hDownload) ; Get all information. InetClose($hDownload) ; Close the handle to release resourcs. If $aData[4] <> 0 then GUICtrlSetData($Label_MinsLeft[$x], "Download ERR") GUICtrlSetColor($Label_MinsLeft[$x], 0xff0000) ; Red GUICtrlSetData($Progress[$x], "0") Sleep(20) $line = $line + 20 FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") Download Error. Will try again on next poll" & @CRLF) Else Sleep(20) $line = $line + 20 ;****************************************************************************** ;Interrogating the CRL with Certutil.exe and dumping to file $CertUtilLogs = FileOpen($s_Environment[$x] & "\" & $s_Endpoint[$x] & ".txt", 2) If $CertUtilLogs = -1 Then MsgBox(16, "Error", "Unable to create CRL Dump file. May be a file permission problem." & @CRLF & @CRLF & "Press OK to exit this application.") Exit EndIf local $Run = Run(@ComSpec & " /c " & "certutil.exe " & $s_Environment[$x] & "\" & $s_Endpoint[$x] & ".crl", "", @SW_HIDE, $STDOUT_CHILD) local $Certutilline Sleep(20) While 1 $Certutilline = StdoutRead($Run) If @error Then ExitLoop Sleep(20) FileWriteLine($CertUtilLogs, $Certutilline) Wend FileClose($CertUtilLogs) Sleep(20) ;****************************************************************************** ;****************************************************************************** ;Opening dumped file and processing to look for effective and expity date to calculate CRL duration $FILE = FileOpen($s_Environment[$x] & "\" & $s_Endpoint[$x] & ".txt", 0) If $FILE = -1 Then MsgBox(16, "Error", "Unable to open Certutil file for some reason. File may be in use when trying to open it." & @CRLF & @CRLF & "Press OK to exit this application.") Exit EndIf While 1 $READLINE = FileReadLine($FILE) If @error = -1 Then ExitLoop $Effective_date = StringRegExp($READLINE, ' ThisUpdate: (.*)', 2) For $I = 0 To UBound($Effective_date) - 1 $Effective_dateData = $Effective_date[1] Next $Expiry_Details = StringRegExp($READLINE, ' NextUpdate: (.*)', 2) For $I = 0 To UBound($Expiry_Details) - 1 $Expiry_DetailsData = $Expiry_Details[1] Next WEnd FileClose($FILE) ;****************************************************************************** ;****************************************************************************** ;Reformatting expiry details to suite date/time convention $date = StringSplit($Expiry_DetailsData, " ") ; Format the time If $date[3] = "PM" Then $hour = StringSplit($date[2], ":") If $hour[1] = 12 Then $hoursplit = 12 Else $hoursplit = $hour[1] + 12 If $hoursplit = 24 Then $hoursplit = 0 Else $hoursplit = $hour[1] + 12 EndIf EndIf EndIf If $date[3] = "AM" Then $hour = StringSplit($date[2], ":") $hoursplit = $hour[1] If $hoursplit = 12 Then $hoursplit = 0 Else $hoursplit = $hour[1] EndIf EndIf ;format the date $datesplit = StringSplit($date[1], "/") $FormattedDate = $datesplit[3] & "/" & $datesplit[2] & "/" & $datesplit[1] & " " & $hoursplit & ":" & $hour[2] & ":00" ;Date difference to _NowCalc() for minutes to expiry $iDateCalc = _DateDiff('n', _NowCalc(), $FormattedDate) ;****************************************************************************** ;****************************************************************************** ;Reformatting effective details to suite date/time convention $date1 = StringSplit($Effective_dateData, " ") ; Format the time If $date1[3] = "PM" Then $hour1 = StringSplit($date1[2], ":") If $hour1[1] = 12 Then $hoursplit1 = 12 Else $hoursplit1 = $hour1[1] + 12 If $hoursplit1 = 24 Then $hoursplit1 = 0 Else $hoursplit1 = $hour1[1] + 12 EndIf EndIf EndIf If $date1[3] = "AM" Then $hour1 = StringSplit($date1[2], ":") $hoursplit1 = $hour1[1] If $hoursplit1 = 12 Then $hoursplit1 = 0 Else $hoursplit1 = $hour1[1] EndIf EndIf ;format the date $datesplit1 = StringSplit($date1[1], "/") $FormattedDate1 = $datesplit1[3] & "/" & $datesplit1[2] & "/" & $datesplit1[1] & " " & $hoursplit1 & ":" & $hour1[2] & ":00" ;Date difference to _NowCalc() $iDateCalc1 = _DateDiff('n', $FormattedDate1, _NowCalc()) $iDateCalc2 = _DateDiff('n', $FormattedDate1, $FormattedDate) $ResultPercent = (($iDateCalc1 / $iDateCalc2) * 100) ;****************************************************************************** ;****************************************************************************** GUICtrlSetData($Progress[$x], $ResultPercent) If $iDateCalc >= $WarningThreshold Then GUICtrlSetData($Label_MinsLeft[$x], $iDateCalc) GUICtrlSetColor($Label_MinsLeft[$x], 0x000000) ; Black GUICtrlSetColor($Progress[$x], 0x33FF00) ; Green If $Status[$x] = "EXPIRED" OR $Status[$x] = "SOON" Then $s_Subject = $s_FromName & " - CRL (" & $s_Endpoint[$x] & ") *** RESOLVED ***" $as_Body[0] = "Message @ " & _NowCalc() & @CRLF $as_Body[1] = "CRL (" & $s_Endpoint[$x] & ") new expiry time is now: " & $FormattedDate & @CRLF & @CRLF & "CRL had been expired for (" & $StatusCount[$x] & ") Counts." & @CRLF & "If Counts = () then the CRL has updated from 'Expiring Soon' status or CRL resolved within one poll." & @CRLF & @CRLF & "Endpoint URL: " & $s_URL[$x] $ToAddressArray = StringSplit($s_ToAddress, ";") For $y = 1 to $ToAddressArray[0] $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $ToAddressArray[$y], $s_Subject, $as_Body, $s_helo, $s_first) $ERR = @error If $Response = 1 Then FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") new expiry time is now: " & $FormattedDate & "CRL had been expired for (" & $StatusCount[$x] & ") Counts." & @CRLF & "If Counts = () then the CRL has updated from 'Expiring Soon' status or CRL resolved within one poll. Email sent to: " & $ToAddressArray[$y] & ". Email Status: OK" & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): OK") Else FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") new expiry time is now: " & $FormattedDate & "CRL had been expired for (" & $StatusCount[$x] & ") Counts." & @CRLF & "If Counts = () then the CRL has updated from 'Expiring Soon' status or CRL resolved within one poll. Email sent to: " & $ToAddressArray[$y] & ". Email Status: NOT SENT, Err: " & $ERR & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): ERROR" & $ERR) EndIf Sleep(20) Next EndIf $Status[$x] = "" $StatusCount[$x] = "" EndIf If $iDateCalc < $WarningThreshold And $iDateCalc >= 1 And Not $iDateCalc < 1 Then GUICtrlSetData($Label_MinsLeft[$x], $iDateCalc & " (Expires Soon)") GUICtrlSetColor($Label_MinsLeft[$x], 0x6600CC) ; Purple GUICtrlSetColor($Progress[$x], 0x6600CC) ; Purple $s_Subject = $s_FromName & " - CRL (" & $s_Endpoint[$x] & ") Expires in " & $iDateCalc & " Minutes" $as_Body[0] = "Message @ " & _NowCalc() & @CRLF $as_Body[1] = "CRL (" & $s_Endpoint[$x] & ") expiry time is: " & $FormattedDate & @CRLF & @CRLF & "Endpoint URL: " & $s_URL[$x] $ToAddressArray = StringSplit($s_ToAddress, ";") For $y = 1 to $ToAddressArray[0] $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $ToAddressArray[$y], $s_Subject, $as_Body, $s_helo, $s_first) $ERR = @error If $Response = 1 Then FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") expires in " & $iDateCalc & " Minutes. Expiry time: " & $FormattedDate & ". Email sent to: " & $ToAddressArray[$y] & ". Email Status: OK" & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): OK") Else FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") expires in " & $iDateCalc & " Minutes. Expiry time: " & $FormattedDate & ". Email sent to: " & $ToAddressArray[$y] & ". Email Status: NOT SENT, Err: " & $ERR & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): OK") EndIf Sleep(20) Next $Status[$x] = "SOON" $StatusCount[$x] = "" EndIf If $iDateCalc < 1 Then GUICtrlSetData($Label_MinsLeft[$x], "EXPIRED") GUICtrlSetColor($Label_MinsLeft[$x], 0xff0000) ; Red GUICtrlSetData($Progress[$x], 100) GUICtrlSetColor($Progress[$x],0xff0000) ; Red If $Status[$x] = "EXPIRED" Then $StatusCount[$x] = $StatusCount[$x] + 1 GUICtrlSetData($Label_MinsLeft[$x], "EXPIRED" & " (" & $StatusCount[$x] & ")") Else $s_Subject = $s_FromName & " - CRL (" & $s_Endpoint[$x] & ") has *** EXPIRED ***" $as_Body[0] = "Message @ " & _NowCalc() & @CRLF $as_Body[1] = "CRL (" & $s_Endpoint[$x] & ") expired at: " & $FormattedDate & ". " & @CRLF & "Please contact the CRL privider and let them know their CRL has expired." & @CRLF & @CRLF & "Endpoint URL: " & $s_URL[$x] $ToAddressArray = StringSplit($s_ToAddress, ";") For $y = 1 to $ToAddressArray[0] $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $ToAddressArray[$y], $s_Subject, $as_Body, $s_helo, $s_first) $ERR = @error If $Response = 1 Then FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") EXPIRED at: " & $FormattedDate & ". Email sent to: " & $ToAddressArray[$y] & ". Email Status: OK" & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): OK") Else FileWriteLine($LOG, _NowCalc() & " ---> CRL (" & $s_Endpoint[$x] & ") EXPIRED at: " & $FormattedDate & ". Email sent to: " & $ToAddressArray[$y] & ". Email Status: NOT SENT, Err: " & $ERR & @CRLF) GUICtrlSetData($SMTPLabel, "Last Email Sent about: (" & $s_Endpoint[$x] & "): ERROR" & $ERR) EndIf Sleep(20) Next EndIf $Status[$x] = "EXPIRED" EndIf FileDelete($s_Environment[$x] & "\" & $s_Endpoint[$x] & ".txt") FileDelete($s_Environment[$x] & "\" & $s_Endpoint[$x] & ".crl") EndIf Next GUICtrlSetData($LastUpdate, "Last Updated: " & _NowCalc()) $line = 40 ;****************************************************************************** ;****************************************************************************** GUICtrlSetData($RefreshButton, "Manual Refresh") GUICtrlSetState($RefreshButton, $GUI_ENABLE) GUICtrlSetData($RefreshProgress, 0) $Timer = TimerInit() $ProgressStep = "" While 1 $msg = GUIGetMsg() Select Case $msg = $RefreshButton GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) GUICtrlSetData($RefreshProgress, 0) $Timer = TimerInit() ExitLoop Case $msg = $GUI_EVENT_CLOSE GUIDelete() FileClose($FILE) FileClose($CertUtilLogs) FileClose($LOG) Exit EndSelect GUICtrlSetData($RefreshProgress, (TimerDiff($Timer) / $TimerValue * 100)) If TimerDiff($Timer) > $TimerValue Then GUICtrlSetData($RefreshProgress, 0) $Timer = TimerInit() GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) ExitLoop EndIf WEnd WEnd Func XPStyleToggle($OnOff = 1) If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0 If $OnOff Then $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties") DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) Return 1 ElseIf IsArray($XS_n) Then DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0]) $XS_n = "" Return 1 EndIf Return 0 EndFunc config.ini file ;---------------------------------------------------------------------------------------------------------------- ; This is the config file for the CRL Endpoint Check. Some settings have minimum values ; ; RefreshTimeMins has a minimum value of 2 and if set below will default to 2 ; WarningThreshold has a minimum value of 20 and if set below will default to 20 ;---------------------------------------------------------------------------------------------------------------- [MailSettings] SMTPServer=***SMTP Server**** FromName=CRL Endpoint Check v3.2.2 FromAddress=***Email address to send from*** [Settings] InputCSV=CRL_Check.csv RefreshTimeMins=10 WarningThreshold=45 LogFileName=Log.txt Sample CRL_Check.csv file Environment,CRLAliasname,http://someaddress/crl.crl,someemail@somedomain.com;anotheremaill@someotherdomain.com
    1 point
×
×
  • Create New...