Sign in to follow this  
Followers 0
llewxam

INFSniff & DeviceInstall

50 posts in this topic

I have put together a tool that some technicians will enjoy, these 2 scripts will

  • Unpack INF files from 7z DriverPacks bundles and scan them for HWIDs
  • Put a list of HWIDs and where they came from in a file and add the DeviceInstall app in the folder containing the DriverPacks
  • DeviceInstall does the installation work
I recommend having 3 folders - "NT5", "NT6 X86", and "NT6 X64". Run INFSniff on each folder, and you will have what you need to install drivers on any platform XP and up. NOTE, this WILL NOT WORK for Win2000, the DeviceAPI functions do not get along with it.

REQUIREMENTS:

Download the drivers from http://driverpacks.net/driverpacks/latest for the type of Windows install you want.

If you are compiling DeviceInstall from the source, you must have the following files in the script directory:

DeviceAPI.AU3 available at http://www.autoitscript.com/forum/index.php?showtopic=77731&hl=deviceapi&st=0 (I am using Alpha6, latest as of posting)

7z.exe (I am using V4.65.0.0)

7z.dll (I am using V4.65.0.0) (both can be pulled from the 7z installation folder)

dpinst.exe (32 and 64 bit versions) as well as dpinst.xml (I am using V2.1.0.0 available as part of Windows Driver Kit Version 7.1.0 available at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff)

*name the 64 bit build of dpinst as "dpinst64.exe"

If you are compiling INFSniff from the source, you must have the following files in the script directory:

DeviceInstall.exe compiled

7z.exe

7z.dll

Source for INFSniff

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~  DriverPacks.net HWID extractor
;~  AKA
;~  INFSniff
    
;~  Coded by Ian Maxwell (llewxam @ www.driverpacks.net & www.autoitscript.com forums)
;~  AutoIt 3.3.6.1
;~  Folder recursion routine by weaponx @ www.autoitscript.com forum


#include "Array.au3"
#include "StaticConstants.au3"

Local $foundINF, $HWIDsplit, $HWIDArray[1]

$startDir = FileSelectFolder("Select the folder containing the DriverPacks", "")
$DP = FileFindFirstFile($startDir & "\*.7z")

FileInstall("7z.exe", @TempDir & "\7z.exe", 1)
FileInstall("7z.dll", @TempDir & "\7z.dll", 1)
FileInstall("DeviceInstall.exe", $startDir & "\DeviceInstall.exe", 1)

$showProg = GUICreate("INFSniff - MaxImuM AdVaNtAgE SofTWarE (C) 2010", 600, 50, @DesktopWidth / 2 - 300, @DesktopHeight / 2 - 100)
$showCurrentName = GUICtrlCreateLabel("", 5, 5, 590, 20, $SS_CENTER)
$prog = GUICtrlCreateProgress(5, 25, 590, 20)
GUISetState(@SW_SHOW, $showProg)

Do
    $file = FileFindNextFile($DP)
    If @error Then ExitLoop

    ;create a temp folder for cleanup later
    $rand = Random(200, 5000, 1)
    $folder = @TempDir & "\" & $rand
    $trimLength = StringLen($folder) + 1

    GUICtrlSetData($showCurrentName, "Please wait, extracting INFs from " & $startDir & "\" & $file)
    RunWait(@TempDir & "\7z.exe x " & Chr(34) & $startDir & "\" & $file & Chr(34) & " -o" & Chr(34) & $folder & Chr(34) & " *.inf -r -y", "", @SW_HIDE) ;extract all INFs from the current DriverPack
    $foundINF = ""
    _Recursion($folder) ;find the INFs

    $INFList = StringSplit(StringTrimRight($foundINF, 1), Chr(2)) ;break the string in to an array

    For $a = 1 To $INFList[0]
        GUICtrlSetData($prog, $a / $INFList[0] * 100)
        GUICtrlSetData($showCurrentName, $INFList[$a])

        $namePrep = StringTrimLeft($INFList[$a], $trimLength) ;lists the name of the current INF and it's path in the DP archive
        $where = StringInStr($namePrep, "\", 0, -1) - 1
        $listName = StringMid($namePrep, 1, $where) ;strips the path from the current INF

        $index = _ArraySearch($HWIDArray, $file & Chr(2) & $listName & Chr(2))
        If $index < 1 Then _ArrayAdd($HWIDArray, $file & Chr(2) & $listName & Chr(2))
        $listNameIndex = _ArraySearch($HWIDArray, $file & Chr(2) & $listName & Chr(2))

        $man = IniReadSection($INFList[$a], "Manufacturer")
        If @error <> 1 Then
            For $b = 1 To $man[0][0]
                $manList = $man[$b][1]
                If StringInStr($manList, ",") Then ;multiple items in [Manufacturer]
                    $manBreak = StringSplit($manList, ",")
                    $mainMan = $manBreak[1] ;"primary" manufacuter item, is used later
                    $HWID = IniReadSection($INFList[$a], $mainMan)
                    If @error <> 1 Then
                        For $c = 1 To $HWID[0][0]
                            _Rip() ;gets info from first item in [Manufacturer]
                        Next
                        For $d = 2 To $manBreak[0]
                            $indivMan = StringStripWS($manBreak[$d], 8)
                            $HWID = IniReadSection($INFList[$a], $mainMan & "." & $indivMan)
                            If @error <> 1 Then
                                For $c = 1 To $HWID[0][0]
                                    _Rip() ;gets the remaining items from [Manufacturer]
                                Next
                            EndIf
                        Next
                    EndIf
                Else ;only one item in [Manufacturer]
                    $HWID = IniReadSection($INFList[$a], $manList)
                    If @error <> 1 Then
                        For $c = 1 To $HWID[0][0]
                            _Rip()
                        Next
                    EndIf
                EndIf
            Next
        EndIf
    Next

    DirRemove($folder, 1)
    GUICtrlSetData($prog, 0)

Until 1 = 2
GUIDelete($showProg)

;delete previous repository if already present
FileDelete($startDir & "\HWIDrepository.txt")
$output = FileOpen($startDir & "\HWIDrepository.txt", 1)
FileWriteLine($output, _ArrayToString($HWIDArray, Chr(4), 1))
FileClose($output)

MsgBox(0, "Done", "Finished sniffing the INFs, the output has been saved to:" & @CR & $startDir & "\HWIDrepository.txt")
Exit


Func _Rip()

    If StringInStr($HWID[$c][1], ",") = 0 And StringInStr($HWID[$c][1], "\") <> 0 Then
        If StringInStr($HWID[$c][1], ";") = 0 Then $HWIDArray[$listNameIndex] &= StringStripWS($HWID[$c][1], 8) & Chr(3)
        If StringInStr($HWID[$c][1], ";") Then
            $semiTrim = StringSplit($HWID[$c][1], ";")
            $HWIDArray[$listNameIndex] &= StringStripWS($semiTrim[1], 8) & Chr(3)
        EndIf
    EndIf
    If StringInStr($HWID[$c][1], ",") Then
        $HWIDsplit = StringSplit($HWID[$c][1], ",")
        For $l = 1 To $HWIDsplit[0]
            If StringInStr($HWIDsplit[$l], "\") Then
                If StringInStr($HWIDsplit[$l], ";") = 0 Then $HWIDArray[$listNameIndex] &= StringStripWS($HWIDsplit[$l], 8) & Chr(3)
                If StringInStr($HWIDsplit[$l], ";") Then
                    $semiTrim = StringSplit($HWIDsplit[$l], ";")
                    $HWIDArray[$listNameIndex] &= StringStripWS($semiTrim[1], 8) & Chr(3)
                EndIf
            EndIf
        Next
    EndIf

EndFunc   ;==>_Rip


Func _Recursion($folder, $depth = 0)

    If $depth = 0 Then Global $RFSstring = ""

    $search = FileFindFirstFile($folder & "\*.*")
    If @error Then Return

    ;Search through all files and folders in directory
    While 1
        $next = FileFindNextFile($search)
        If @error Then ExitLoop

        ;If folder, recurse
        If StringInStr(FileGetAttrib($folder & "\" & $next), "D") Then
            _Recursion($folder & "\" & $next, $depth + 1)
        Else
            ;Append filename to master string
            If StringLower(StringRight($folder & "\" & $next, 3)) = "inf" Then $foundINF &= $folder & "\" & $next & Chr(2)
        EndIf
    WEnd
    FileClose($search)

    If $depth = 0 Then Return StringSplit(StringTrimRight($RFSstring, 1), "*")
EndFunc   ;==>_Recursion

Source for DeviceInstall:

#RequireAdmin
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=DeviceInstall.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~  Driver Installer V2
;~  Coded by Ian Maxwell (llewxam @ www.driverpacks.net & www.autoitscript.com forums)
;~  AutoIt 3.3.6.1
;~  DeviceAPI & folder recursion routines by weaponx @ www.autoitscript.com forum

#include "DeviceAPI.au3"
#include "Array.au3"
#include "GUIConstantsEx.au3"
#include "StaticConstants.au3"


If @OSVersion == "WIN_2000" Then
    MsgBox(0, "Unsupported OS", "Due to API issues, Windows 2000 is not supported at this time.")
    Exit
EndIf

Local $HWID, $foundLocations, $installed, $matches, $OSArch = @OSArch

FileInstall("7z.exe", @TempDir & "\7z.exe", 1)
FileInstall("7z.dll", @TempDir & "\7z.dll", 1)

$rand = Random(200, 5000, 1)
$folder = @TempDir & "\" & $rand
DirCreate($folder)

;Build list of devices
_DeviceAPI_GetClassDevices()

;Loop through all devices by index, strip out ones without a HWID
While _DeviceAPI_EnumDevices()
    $haveHWID = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID)
    If $haveHWID <> "" Then
        $HWID &= _DeviceAPI_GetDeviceRegistryProperty($SPDRP_DEVICEDESC) & Chr(2) & _DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID) & Chr(2)
    EndIf
WEnd
$localHWID = StringSplit(StringTrimRight($HWID, 1), Chr(2))

$GUIWidth = @DesktopWidth - 100
$main = GUICreate("Driver Installer v2 - MaxImuM AdVaNtAgE SofTWarE (C) 2010", $GUIWidth, 145, 50, 1)
$currentDeviceName = GUICtrlCreateLabel("", 5, 5, $GUIWidth - 10, 20)
$currentDeviceID = GUICtrlCreateLabel("", 5, 25, $GUIWidth - 10, 20, $SS_NOPREFIX)
$info = GUICtrlCreateLabel("", 5, 65, $GUIWidth - 10, 40)
$prog = GUICtrlCreateProgress(5, 120, $GUIWidth - 10, 20)
GUISetState(@SW_SHOW, $main)

$input = FileOpen("HWIDrepository.txt", 0)
$HWIDRead = FileRead($input)
FileClose($input)
$HWIDArray = StringSplit($HWIDRead, Chr(4))


For $a = 1 To $localHWID[0] Step 2

    GUICtrlSetData($prog, $a / $localHWID[0] * 100)
    GUICtrlSetData($currentDeviceName, "Device Name: " & $localHWID[$a])
    GUICtrlSetData($currentDeviceID, "HWID: " & StringUpper($localHWID[$a + 1]))
    GUICtrlSetData($info, "Looking for device driver matches")

    $specific = "" ;not used, but could be to further refine the results
    $generic = $localHWID[$a + 1]
    If StringInStr($generic, "SUBSYS") Then
        $break = StringSplit($generic, "SUBSYS", 1)
        $generic = StringTrimRight($break[1], 1)
        $specific = $break[2]
    EndIf

    For $b = 1 To $HWIDArray[0]
        $description = StringSplit($HWIDArray[$b], Chr(2))
        If $description[3] <> "" Then
            $actualHWID = StringSplit($description[3], Chr(3))
            For $c = 1 To $actualHWID[0] - 1
                If StringInStr($actualHWID[$c], $generic) Then
                    $matches &= $description[1] & Chr(2) & $description[2] & Chr(2) & $localHWID[$a] & Chr(3)
                    ContinueLoop (2)
                EndIf
            Next
        EndIf
    Next
Next
$splitMatches = StringSplit(StringTrimRight($matches, 1), Chr(3))
$unique = _ArrayUnique($splitMatches, 1, 1)

GUICtrlSetData($prog, 0)
GUICtrlSetData($currentDeviceName, "")
GUICtrlSetData($currentDeviceID, "")

If $unique[0] > 1 Then
    For $a = 1 To $unique[0]
        $location = StringSplit($unique[$a], Chr(2))
        GUICtrlSetData($info, "Found matches, extracting " & $location[2] & " from " & $location[1])
        RunWait(@TempDir & "\7z.exe x " & $location[1] & " -o" & $folder & " " & $location[2] & " -r -y", "", @SW_HIDE) ;extract the current driver from the DriverPack
        If $OSArch = "X86" Then FileInstall("dpinst.exe", $folder & "\" & $location[2] & "\dpinst.exe", 1)
        If $OSArch = "X64" Then FileInstall("dpinst64.exe", $folder & "\" & $location[2] & "\dpinst.exe", 1)
        FileInstall("dpinst.xml", $folder & "\" & $location[2] & "\dpinst.xml", 1)
        $foundLocations &= $folder & "\" & $location[2] & Chr(2) & $location[1] & Chr(2) & $location[3] & Chr(2)
        GUICtrlSetData($prog, $a / $unique[0] * 100)
    Next

    GUICtrlSetData($currentDeviceName, "")
    GUICtrlSetData($currentDeviceID, "")
    GUICtrlSetData($prog, 0)
    $breakLocations = StringSplit(StringTrimRight($foundLocations, 1), Chr(2))

    For $a = 1 To $breakLocations[0] Step 3
        GUICtrlSetData($info, "Installing " & $breakLocations[$a + 2] & " driver")
        ShellExecuteWait($breakLocations[$a] & "\dpinst.exe", "/S /SA /SE /SW")
        GUICtrlSetData($prog, $a / $unique[0] * 100)
        $installed &= $breakLocations[$a + 2] & Chr(2)
    Next
    $showInstalled = StringSplit(StringTrimRight($installed, 1), Chr(2))

    GUIDelete($main)
    $showGUI = GUICreate("Installed Divers", 600, 200, 1, 1)
    $showList = GUICtrlCreateList("", 5, 5, 590, 190)
    GUISetState(@SW_SHOW, $showGUI)

    For $a = 1 To $showInstalled[0]
        GUICtrlSetData($showList, $showInstalled[$a])
    Next
Else
    MsgBox(0, "Nothing to update", "There are no drivers avaiable that are compatible with your computer.")
    DirRemove($folder, 1)
    Exit
EndIf

Do
    $msg = GUIGetMsg()
    If $msg = $gui_event_close Then
        DirRemove($folder, 1)
        Exit
    EndIf
Until 1 = 2

It is tested but only on a handful of machines, I thought it would be more fun to release it now as-is rather than sit on it for a while :mellow:

Enjoy

Ian

1 person likes this

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites



G'day Ian

I haven't had a chance to try it yet. (lots of things to collect before I can use it :mellow:)

BUT!

Looks good I'll give it a try as soon as I have a bit of time. I did "try" and use the driver packs soem tiem ago when I had a computer that I coudln't find the driver for but I couldn't find the right one and gave up and found another solution. Pitty I didnt' have this back then.

Thanks!

Hope you had a great weekend!

John Morrison

AKA

Storm-E

Share this post


Link to post
Share on other sites

LOL, I knew that if anyone would find this interesting it would be you, since we do similar things to earn a living! :mellow:

DriverPacks are great, I have used them for several years to make life easier in a number of ways. I used to just extract them to DVD and let Windows search the disc to find a needed driver, then I used several slipstreaming methods for my SysPrepped images to make them hardware-agnostic, and in January 2009 I came to the point where I was ready to make an installer by HWID. That tool was the first thing I ever wrote in AutoIt, and lemme tell ya, it was CLUNKY!! :P But after a while it worked and proved the point that it was a valid method. This re-write (hence V2 in the code) is a major improvement.

Soooo, grab all of the DriverPacks archives, put them in their proper folders by OS/Arch, run INFSniff on the folders, and then either burn them to DVD, use a network share, flash drive, whatever suits you, I use all 3 on a daily basis.

Enjoy

Ian

PS - Don't forget to check out the DriverPacks forum, there are only a handful of people who make the packs possible, any feedback/driver fills are greatly appreciated, and they have some great integration tools of their own.


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nice script! Looks like the project I've been working on for the DriverPacks team called FindHWIDS -- http://forum.driverpacks.net/viewtopic.php?id=3018

I also wrote DriverGeek and DriverForge (depreciated)... :graduated:

Full version history if you want some insights ---

v3.2m @ 2010-04-18 -

-- Fixed some wording issues

-- Re-organized installed files and cleanup

v3.2l @ 2009-12-13 -

-- Hopefully fixed the issue with selecting OS Arch and OS Type

v3.2j @ 2009-06-22 -

-- Added filters for processor arch and os version, you must select BOTH an OS version and processor architecture

-- Fix scan count again, will only count true/real INF files

-- Sysprep will not automatically select only currently installed hardware, so a user can select the OS Version and Processor Arch offline if needed

v3.2i @ 2009-04-29 -

-- Improves speed during filter searches

v3.2h @ 2009-04-11 -

-- Added ability to set CSV and Sysprep filenames and locations. If you don't use the default sysprep location it will warn you that sysprep will not process. All Warning and a Error messages will close after 5 seconds and will bring you back to the Main window.

-- Added a progress bar that will show the total amount of INF files scanned, so the user has some feedback on how long the process is taking

-- If the CSV file already exists it will delete it NOT append to it. If the sysprep.inf file exists it will append to it, if the file does not exist but the location is writeable a file will be created.

v3.2g @ 2009-04-02 -

-- Fixed issues with OS type and OS Arch filters filtering properly

-- Added 2008 and Vista to OS type and OS arch filter

-- At start of scan window will minimize, at end of scan window will restore

-- Choosing no export types will show a prompt telling you to choose an export type

-- Changed Export Hardware list with an additional Service property and changed arrangement of output

v3.2f @ 2009-03-20 -

-- Changed so that you can export multiple types at a time (getting ready for reg import, oempnpdrivers section)

-- Removed Excel functionality because:

---- 1) Excel dependency and

---- 2) CSV is faster and produces the same output and

---- 3) Having to edit both the CSV and Excel to look the same was annoying

-- Improved GUI look and added banner

-- Improved and cleaned up some backend code

v3.2e @ 2009-02-27 -

-- Fixes tip help from "comma" to "Pipe symbol"

-- Fixes some internals issues with deleting old export hardware profile

-- Changed visuals to all display internally on main window, exporting hardware profile will not show tooltip

-- More visual changes - clear button for locations, filters

-- Fixes main window on top issue when browsing for folder/file locations

v3.2d @ 2009-02-26 -

-- Fixed issue with timers displaying properly.

-- Speeds up exporting via Excel by hiding Excel

-- Adds ClassGUID to outputs Excel and CSV

-- Change GUI background to white

-- Scanning process no longer minimizes main window and adds Tooltip processing. Processing staying in main window and updates Statusbar area.

-- Fixes issue with _INIReadSectionEx to skip commented out lines.

-- Fixes issue with adding any HWID filters. You must use the Pipe symbol on all filter seperations. Updated the help functions to coincide with changes.

v3.2c @ 2009-02-26 - Add ClassGUID to output.

v3.2b @ 2009-02-24 - Fixed issue with counting INF files scanned. Changed exit function to delete only data it put there. Fixes issue with the inireadsection not grabbing data over 32k, now using Smoke_N UDF to pull data from the sections. Will now pull all HWIDS! This version DOES NOT scan for duplicate files.

v3.2.1 @ 2008-11-02 6:55pm EST - (NOT RELEASED) Added a function to scan for duplicate inf files.

v3.2 @ 2008-10-26 11:48pm EST - Created a function to scan for variables within the INF. Reducing bad data (hopefully eliminated). Scan speed is about the same.

v3.1.9.1 @ 2008-10-23 2:19pm EST - Scan time has also been reduced about 20%.

v3.1.9 @ 2008-10-23 11:49pm EST - Fixed flawed logic with strings. Hopefully rebuilding soon with a better way of handling strings. Though this version fixes some missed converting of strings into hwids.

v3.1.8 @ 2008-10-22 6:28pm EST - Adds install as an option (with DPinst.exe 32bit english only, copyright Microsoft), installing only hardware found on machine. Improves on scanning speed. Fixes some strings issue.

v3.1.7 @ 2008-09-28 5:42pm EST - Adds scan time, files scanned and hwids found to excel and csv output. Moved scanning of certain parts of the INF to produce a faster scan. Changed during scan the FindHWIDs window now minimizes.

v3.1.6 @ 2008-09-28 4:41pm EST - Fixes CSV output to mimic Excel output. Now exports the INF Description (also still outputs the PNPID description)

v3.1.5 @ 2008-09-26 11:03am EST - Added OS and OS Architecture as a filter. Choosing sysprep output will automatically choose filtering of OS and OS architecture. You can split multiple folders/files with a pipe symbol to scan granularly.

v3.1.3 @ 2008-09-26 11:03am EST - Changed find hash to use a dll instead. Much faster, in fact almost as fast as native scanning. Adding MD5 and Class to csv output.

v3.1.2 @ 2008-09-26 10:46am EST - Added md5deep to check hashing, however this version is extremely slow.

v3.1.1 @ 2008-09-26 8:24am EST - Changes Sysprep to scan for only SCSIAdapter and HDC. Corrected hardware filter for OS and Arch types.

v3.1 @ 2008-09-23 3:04pm EST - Adds functionality to the hardware filter to filter OS and architecture. Still debating whether to have System class for Sysprep.inf exports

v3.0.9 @ 2008-09-23 11:29pm EST - About is now a text file so users can see full change log. When you press Esc the program will now exit. Added more fixes for string management. The program will tell you if it the INF file does not have the appropriate data included. You can now drag and drop multiple files and folders into the input box. You can also mix files or folders together.

v3.0.8 @ 2008-09-22 7:32pm EST - INTERNAL - fixed some issues, don't remember :|

v3.0.7 @ 2008-09-22 6:04pm EST - Rebuilt functions to grab Manufacturer and other strings. Should reduce bad data.

v3.0.6 @ 2008-09-22 2:21pm EST - Created a new function to strip strings of certain items to reduce or eliminate bad data. Exported data will now save to a temp folder if it cannot write to the current directory. Fixed issue with opening the hardware export log on x64 machines. Should also see a little speed increase. You can drag and drop a file or folder to search into the location input box.

v3.0.5 @ 2008-09-18 2:18pm EST - Adds exporting of only the found HWIDS from the current system. Also, the ability capture just the hardware in the system to a log file. Same as sav_hwid.exe. New feature take advantage of WMI.

v3.0.4 @ 2008-09-18 2:18pm EST - Fixes a couple grammatical errors. Added ability to search for one or more specific PNP ID's.

v3.0.3 @ 2008-09-18 12:04am EST - Fixes quotes in HWID string.

v3.0.2 @ 2008-09-17 11:47pm EST - Added ability to filter classes. Updated the GUI to reflect extra options. Added an about button. Excel minimizes during Excel export. Sysprep only exports classes SCSIAdapter, HDC and System. Add ability to scan a specific INF file or a folder of INF files recursively.

v3.0.1 @ 2008-09-15 10:59pm EST - Adds some fixes for Sysprep to only export SCSIAdapter and HDC hwid types. Export to Excel gives more information. The GUI has changed and is a bit easier to use.

v2.9 @ 2008-09-11 3:11pm EST - Added more information that's parsed to excel. Fixed a couple issues with parsed information. Changed what's displayed in the tooltip area.

v2.8 @ 2008-09-11 11:19pm EST - Adds ability to export to an Excel spreadsheet. You must have Word installed in order for this to work. You can type excel into the option instead of sysprep or cvs.

v2.7 @ 2008-09-11 7:51pm EST - Fixed issues for string Manufacturers with quotes in value.

v2.6 @ 2008-09-11 11:08am EST - Fixed an issue with HWIDS that could be blank

v2.5 @ 2008-09-11 9:42am EST - Completely changed logic of scanning again (third times the charm). Scans are considerably faster and as accurate as I think they'll ever be.

v2.4 @ 2008-09-08 1:03pm EST - Changed everything this time around, new logic for finding HWIDS; It doesn't scan for a specific HWID and will do multiple HWIDS inline. Meaning it's more accurate.

v1.9 - INTERNAL Last version that finds HWIDS by HWID type - which isn't as accurate

v1.8 @ 2008-09-03 11:51am EST - Fixed some dyslexia for CSV and CVS; Added Display\, PCIIDE\, IDE\ and ISAPNP\

v1.7 @ 2008-09-02 2:33pm EST - Adds USBSTOR\ and HID\ , Adds a simple GUI for entering location and parse to type

v1.6 @ 2008-09-01 11:00pm EST - Migrated to Array function boosting completion time by 5 times or more (for example scanning Sound, w/ 14,219 HWIDS, took 277 seconds and now takes 54 seconds). Added line number from the INF file to make it easier finding issues with HWIDS.

v1.5 - INTERNAL Added more checks for HKR, HKLM and HKCR because of crazy asterisks

v1.4 @ 2008-09-01 3:18pm EST - Adds AHCI\ and ACPI\ to the parse list - Changed $ParseTo variable to accept both CSV and Sysprep as options

v1.3 - Adds ability to output to CSV and also gets Version - Sysprep is still the same just use blank for $ParseTo

v1.2 - Added checks for USB\ and HDAUDIO\FUNC, ExcludeFromSelect will not be added

v1.1 - Added check for SCSI\, * type and GenNvRaidDisk

v1.0 - Base check HWIDS for on PCI\VEN, will not add commented out lines and will not add end of lines that have been commented out

Edited by kickarse

Share this post


Link to post
Share on other sites

LOL, yeah, I've used that many times in the past, reporting missing drivers etc, and we've spoken before on DP's forum. :(

I posted this to the Testing Team DP forum and got ZERO feedback, at least as of six or so months ago, and decided to not post it to the general forum there but to here instead, since I was more interested in feedback on the code rather than anything else. Maybe I should put a link to this in a public DP area....

Oh, and THANKS for the feedback, much appreciated! :graduated:

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

G'day Ian

Just wanted to say "I Love your program!" :graduated:

It's got me out of so many scrapes!

Well done!

I'm still keen on the idea of automatically updating the files (mine are out of date).

You siad there maybe an INI file on the site or somthing like that.

Could you get back to me with details or tell me the best guy to chat with to get the right information.

Thanks

JOhn Morrison

aka

Storm-E

Share this post


Link to post
Share on other sites

I think Jeff (Overflow) is still the main admin, but MrSmartepants would be who I talked to next.

And THANKS! I use it in my universal XP images (SysPrep + OfflineSysPrep via BartPE + this script = full XP install with ALL Windows Updates and most drivers in 20 minutes!) The only thing I would like to see now is installation directly from the DeviceAPI UDF which WeaponX said he would try to do at some point, that would reduce the required files for this script.

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Danny35d has very kindly put his time and effort toward this script and made some very nice improvements! I am grateful for that, and the result is that the 2 scripts (INFSniff and DeviceInstall) are now merged in to one, the prior use of comparing the local machine HWIDs to the repository of available drivers via array has been totally revamped using SQLite so finding matches is MUCH faster, the creation of a log file at completion, and general bugfixes.

The requisites from the first post have not changed, all files needed to compile then still apply. The only difference is that the folder names used now are NT5, NT6X32, and NT6X64 for saving your DriverPacks to.

Thanks again for your contribution Danny35d!!!!!!!!!!!!! :x:P

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=InfSniff.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


;~ #AutoIt3Wrapper_Icon=Include\Icon_1.ico

;~  DriverPacks.net HWID extractor and installer
;~  AKA
;~  INFSniff

;~  Coded by Ian Maxwell (llewxam @ www.driverpacks.net & www.autoitscript.com forums) with massive contribution from Danny35d!
;~  AutoIt 3.3.6.1
;~  Folder recursion routine by weaponx @ www.autoitscript.com forum
;~  Windows build number http://en.wikipedia.org/wiki/Windows_NT


#include <File.au3>
#include <Array.au3>
#include <SQLite.au3>
#include <DeviceAPI.au3>
#include <sqlite.dll.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

FileInstall('7z.exe', @TempDir & '\', 1)
FileInstall('7z.dll', @TempDir & '\', 1)

Global $TableDb = 'Nt5'
Global $sDeviceName
Global $showInstalled, $info
Global $TempFolder = _TempFile(@TempDir, '', '')
Global $AppLog = StringTrimRight(@ScriptFullPath, 3) & 'Log'
Global $DriversDBFullPath = @ScriptDir & '\HWIDrepository.sqlite'

If FileExists($AppLog) Then FileDelete($AppLog)
If Not FileExists($DriversDBFullPath) Then
    $Rtn = _CreateHwidList()
    $sTitle = 'Done'
    $sMsg = 'Finished sniffing the INFs, the output has been saved to:' & @CR & $DriversDBFullPath
    If $Rtn Then
        FileDelete($DriversDBFullPath)
        $sTitle = 'Warning...'
        $sMsg = 'Failed to create database, please check log: ' & @CRLF & $AppLog
    EndIf
    MsgBox(0, $sTitle, $sMsg)
Else
    If @OSBuild <= 2195 Then ;Windows 2000 and below are unsupported OSes
        $sTitle = 'Unsupported OS'
        $sMsg = 'Due to API issues, Windows ' & StringReplace(@OSVersion, 'win_', '') & ' is not supported at this time.'
    Else
        _SearchingDB()
    EndIf
EndIf

FileDelete(@TempDir & '\7z.*')
Exit

Func _SearchingDB()
    Dim $localHWID[1][2]

    If @OSBuild > 3790 Then $TableDb = 'Nt6' & @OSArch
    ;Build list of devices
    _DeviceAPI_GetClassDevices()
    While _DeviceAPI_EnumDevices()
        $haveHWID = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID)
        If $haveHWID <> '' Then
            ReDim $localHWID[UBound($localHWID) + 1][2]
            $generic = $haveHWID ;_DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID)
            If StringInStr($generic, 'SUBSYS') Then
                $break = StringSplit($generic, 'SUBSYS', 1)
                $generic = StringTrimRight($break[1], 1)
;~              $specific = $break[2] ; Not used, but could be to further refine the results
            EndIf
            $localHWID[UBound($localHWID) - 1][0] = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_DEVICEDESC)
            $localHWID[UBound($localHWID) - 1][1] = $generic
        EndIf
    WEnd
    $localHWID[0][0] = UBound($localHWID) - 1

    FileInstall('dpinst.xml', @TempDir & '\dpinst.xml', 1)
    If @OSArch = 'X86' Then FileInstall('dpinst.exe', @TempDir & '\', 1)
    If @OSArch = 'X64' Then FileInstall('dpinst64.exe', @TempDir & '\dpinst.exe', 1)

    $GUIWidth = @DesktopWidth - 100
    $main = GUICreate('Driver Installer v2 - MaxImuM AdVaNtAgE SofTWarE © 2010', $GUIWidth, 173, 50, 10, $WS_CLIPSIBLINGS)
    $currentDeviceName = GUICtrlCreateLabel('', 5, 5, $GUIWidth - 10, 20)
    $currentDeviceID = GUICtrlCreateLabel('', 5, 25, $GUIWidth - 10, 20, $SS_NOPREFIX)
    $info = GUICtrlCreateLabel('', 5, 65, $GUIWidth - 10, 40)
    $prog = GUICtrlCreateProgress(2, 120, $GUIWidth - 10, 20)
    GUISetState()

    _SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    For $a = 1 To $localHWID[0][0]
        $sDeviceName = $localHWID[$a][0]
        GUICtrlSetData($prog, $a / $localHWID[0][0] * 100)
        GUICtrlSetData($currentDeviceName, 'Device Name: ' & $sDeviceName)
        GUICtrlSetData($currentDeviceID, 'HWID: ' & $localHWID[$a][1])
        GUICtrlSetData($info, 'Looking for device driver matches')
        _SQLite_Exec($hDB1, "SELECT DISTINCT * FROM " & $TableDb & " WHERE hWId = '" & $localHWID[$a][1] & "';", "_InstallingDrivers")
    Next
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()

    If $showInstalled <> '' Then $showInstalled = StringSplit(StringTrimRight($showInstalled, 1), '|')
    GUIDelete($main)
    If IsArray($showInstalled) Then
        $showGUI = GUICreate('Installed Drivers', 600, 200, 1, 1)
        $showList = GUICtrlCreateList('', 5, 5, 590, 190)
        GUISetState(@SW_SHOW, $showGUI)

        For $a = 1 To $showInstalled[0]
            GUICtrlSetData($showList, $showInstalled[$a])
        Next
        Do
            $iMsg = GUIGetMsg()
            Sleep(50)
        Until $iMsg = $GUI_EVENT_CLOSE
    Else
        MsgBox(0, 'Nothing to update', 'There are no drivers avaiable that are compatible with your computer.')
    EndIf

    DirRemove($TempFolder, 1)
    FileDelete(@TempDir & '\dpinst.xml')
    FileDelete(@TempDir & '\dpinst.exe')
EndFunc   ;==>_SearchingDB

Func _InstallingDrivers($aRow)
    If Not StringInStr($showInstalled, $sDeviceName) Then $showInstalled &= $sDeviceName & '|'
    GUICtrlSetData($info, 'Found match, extracting ' & $aRow[2] & ' from ' & $aRow[1])
    $Rtn = RunWait(@TempDir & '\7z.exe x "' & @ScriptDir & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\* -r -y -x!*.inf', @TempDir, @SW_HIDE) ;extract the current driver from the DriverPack
    _FileWriteLog($AppLog, _7zipExitCode($Rtn) & '\7z.exe x "' & @ScriptDir & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\* -r -y -x!*.inf')
    $Rtn = RunWait(@TempDir & '\7z.exe x "' & @ScriptDir & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\' & $aRow[3] & ' -y', @TempDir, @SW_HIDE) ;extract the current driver from the DriverPack
    _FileWriteLog($AppLog, _7zipExitCode($Rtn) & '\7z.exe x "' & @ScriptDir & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\' & $aRow[3] & ' -y')

    If $Rtn <> 0 Then
        GUICtrlSetData($info, 'Failed to unzip drivers.')
    Else
        GUICtrlSetData($info, 'Installing driver.')
        $Rtn = ShellExecuteWait(@TempDir & '\dpinst.exe', '/S /SA /SE /SW /PATH "' & $TempFolder & '\' & $aRow[2] & '"')
        _FileWriteLog($AppLog, 'ExitCode: ' & $Rtn & ' ' & 'dpinst.exe /S /SA /SE /SW /PATH "' & $TempFolder & '\' & $aRow[2] & '"' & @CRLF)
    EndIf
    DirRemove($TempFolder, 1)
EndFunc   ;==>_InstallingDrivers

Func _CreateHwidList()
    Local $HWIDsplit, $DP, $ExitCodeError = False
    Dim $DriversPath[3] = [@ScriptDir & '\Nt5', @ScriptDir & '\Nt6x64', @ScriptDir & '\Nt6x86']

    For $Path In $DriversPath
        If FileExists($Path) Then $DP &= _FileListToArrayEx($Path, '*.7z', 1, 1, 1, '', 0) & '|'
    Next
    If $DP <> '' Then $DP = StringSplit(StringTrimRight($DP, 1), '|')
    If Not IsArray($DP) Then
        MsgBox(48, 'Warning', "Didn't find any Driver Packs 7z files.")
        Exit
    EndIf

    $showProg = GUICreate('INFSniff - MaxImuM AdVaNtAgE SofTWarE © 2010', 600, 100, -1, -1, $WS_CLIPSIBLINGS)
    $showCurrentName = GUICtrlCreateLabel('', 5, 5, 590, 50, $SS_CENTER)
    $prog = GUICtrlCreateProgress(2, 48, 590, 20)
    GUISetState(@SW_SHOW, $showProg)

    _SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt5 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt6x64 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt6x86 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'begin;')

    For $x = 1 To $DP[0]
        GUICtrlSetData($prog, Int($x / $DP[0] * 100))
        GUICtrlSetData($showCurrentName, 'Please wait, extracting INFs from ' & $DP[$x])
        $Rtn = RunWait(@TempDir & "\7z.exe x " & Chr(34) & $DP[$x] & Chr(34) & " -o" & Chr(34) & $TempFolder & Chr(34) & " *.inf -r -y", @TempDir, @SW_HIDE)
        _FileWriteLog($AppLog, _7zipExitCode($Rtn) & "7z.exe x " & Chr(34) & $DP[$x] & Chr(34) & " -o" & Chr(34) & $TempFolder & Chr(34) & " *.inf -r -y")
        If $Rtn <> 0 Then
            $ExitCodeError = True
            ContinueLoop
        EndIf

        $INFList = _FileListToArrayEx($TempFolder, '*.inf', 1, 1, 1)
        $TableToRecord = StringReplace(StringRegExpReplace($DP[$x], "^(.*)\\.*?$", "${1}"), @ScriptDir & '\', '')
        If IsArray($INFList) Then
            For $a = 1 To $INFList[0]
                $FileName = StringRegExpReplace($DP[$x], '^.*\\', '')
                $InfFileName = StringRegExpReplace($INFList[$a], '^.*\\', '')
                $FolderName = StringRegExpReplace(StringReplace($INFList[$a], $TempFolder & '\', ''), "^(.*)\\.*?$", "${1}")
                GUICtrlSetData($showCurrentName, 'Please wait, proccessing INFs ' & $INFList[$a])
                $man = IniReadSection($INFList[$a], 'Manufacturer')
                If @error Then ContinueLoop
                For $b = 1 To $man[0][0]
                    $manBreak = StringSplit($man[$b][1], ',')
                    For $c = 1 To $manBreak[0]
                        If $c = 1 Then
                            $indivMan = StringStripWS($manBreak[$c], 8)
                        Else
                            $indivMan = StringStripWS($manBreak[1] & '.' & $manBreak[$c], 8)
                        EndIf
                        $HWID = IniReadSection($INFList[$a], $indivMan)
                        If @error Then ContinueLoop
                        For $d = 1 To $HWID[0][0]
                            If StringInStr($HWID[$d][1], ',') = 0 And StringInStr($HWID[$d][1], '\') <> 0 Then
                                If StringInStr($HWID[$d][1], ';') Then
                                    $semiTrim = StringSplit($HWID[$d][1], ';')
                                    _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($semiTrim[1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                Else
                                    _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($HWID[$d][1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                EndIf
                            EndIf
                            If StringInStr($HWID[$d][1], ',') Then
                                $HWIDsplit = StringSplit($HWID[$d][1], ',')
                                For $l = 1 To $HWIDsplit[0]
                                    If StringInStr($HWIDsplit[$l], '\') Then
                                        If StringInStr($HWIDsplit[$l], ';') Then
                                            $semiTrim = StringSplit($HWIDsplit[$l], ';')
                                            _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($semiTrim[1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                        Else
                                            _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($HWIDsplit[$l], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                        EndIf
                                    EndIf
                                Next
                            EndIf
                        Next
                    Next
                Next
            Next
        EndIf
        DirRemove($TempFolder, 1)
    Next

    _SQLite_Exec($hDB1, 'commit;')
    GUIDelete($showProg)
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()
    Return ($ExitCodeError)
EndFunc   ;==>_CreateHwidList

Func _7zipExitCode($iExitCode)
    Switch $iExitCode
        Case 0
            $msg = 'Sucessfull : '
        Case 1
            $msg = 'Warning(Non fatal error(s)): '
        Case 2
            $msg = 'Fatal error: '
        Case 7
            $msg = 'Command line error: '
        Case 8
            $msg = 'Not enough memory for operation: '
        Case 255
            $msg = 'User stopped the process: '
        Case Else
            $msg = 'Unknown error: '
    EndSwitch
    Return ($msg)
EndFunc   ;==>_7zipExitCode

; #FUNCTION# ================================================================================
; Name...........: _FileListToArrayEx
; Description ...: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)
; Syntax.........: _FileListToArrayEx($sPath[, $sFilter = "*"[, $iFlag = 0, $iPathType = 1, $iRecursive = 0, $sExclude = "", $iRetFormat = 1]])
; Parameters ....: $sPath   - Path to generate filelist for.
;                  $sFilter - Optional: the filter to use, default is *, semicolon delimited. Search the Autoit3 helpfile for the word "WildCards" For details.
;                             (Example: "*.exe;*.txt")
;                  $iFlag   - Optional: specifies whether to return files folders or both
;                    0 = (Default) Return both files and folders
;                    1 = Return files only
;                    2 = Return Folders only
;                  $iPathType
;                    0 = relative path
;                    1 = (Default) full path
;                  $iRecursive - Search files in specified directory and all subdirectories.
;                    0 = (Default) Search in specified directory.
;                    1 = Search in specified and all subdirectories.
;                  $sExclude = optional: Exclude filter(s), semicolon delimited. Wildcards allowed.
;                    (Example: "Unins*" will remove all files/folders that begin with "Unins")
;                  $iRetFormat =  optional: return format
;                    0 = String ( "|" delimited)
;                    1 = (Default) one-dimensional array, 1-based
;                    2 = one-dimensional array, 0-based
;                  $sDelim - Delimiter for combined string.
; Return values .: @Error -
;                    1 = Path not found or invalid
;                    2 = Invalid $sFilter
;                    3 = Invalid $iFlag
;                    4 = No File(s) Found
;                    5 = Invalid $iPathType
;                    6 = Invalid $iRecursive
;                    7 = Invalid $iRetFormat
; Author ........:
; Modified.......:
; Remarks .......: The array returned is one-dimensional and is made up as follows:
;                    $array[0] = Number of Files\Folders returned
;                    $array[1] = 1st File\Folder
;                    $array[2] = 2nd File\Folder
;                    $array[3] = 3rd File\Folder
;                    $array[n] = nth File\Folder
; Related .......:
; Link ..........;
; Example .......; Yes
; ===========================================================================================

Func _FileListToArrayEx($sPath, $sFilter = '*', $iFlag = 0, $iPathType = 1, $bRecursive = 0, $sExclude = '', $iRetFormat = 1, $sDelim = '|')
    Local $sFile, $hSearch, $sWorkingdir, $asFilelist, $aFolderStack[2]

    $sPath = StringRegExpReplace($sPath, '[\\/]+\z', '')
    If Not FileExists($sPath) Then Return SetError(1, 1, '')
    If $sFilter = '' Or $sFilter = -1 Or $sFilter = Default Then $sFilter = '*'
    If StringRegExp($sFilter, '[:\\</>\|]|(?s)\A\s*\z') Then Return SetError(2, 2, '')
    If Not StringRegExp($iFlag, '[012]') Then Return SetError(3, 3, '')
    If Not StringRegExp($iPathType, '[01]') Then Return SetError(5, 5, '')
    If Not StringRegExp($bRecursive, '[01]') Then Return SetError(6, 6, '')
    If Not StringRegExp($iRetFormat, '[012]') Then Return SetError(7, 7, '')
    $sFilter = StringReplace(StringStripWS(StringRegExpReplace($sFilter, '\s*;\s*', ';'), 3), ';', '|')
    $sMask = '(?i)^' & StringReplace(StringReplace(StringReplace($sFilter, '.', '\.'), '*', '.*'), '?', '.')
    $sExclude = StringStripWS(StringRegExpReplace($sExclude, '\s*;\s*', ';'), 3)
    $sExclude = StringRegExpReplace($sExclude, '([\Q\.+[^]$(){}=!\E])', '\\$1')
    $sExclude = '(?i)\A' & StringReplace(StringReplace(StringReplace($sExclude, '?', '.'), '*', '.*?'), ';', '|') & '\z'

    $aFolderStack[0] = 1
    $aFolderStack[1] = $sPath
    While $aFolderStack[0] > 0
        $sWorkingdir = $aFolderStack[$aFolderStack[0]]
        $aFolderStack[0] -= 1
        $hSearch = FileFindFirstFile($sWorkingdir & '\*')
        While 1
            $sFile = FileFindNextFile($hSearch)
            If @error Then ExitLoop
            If @extended Or StringInStr(FileGetAttrib($sWorkingdir & '\' & $sFile), 'D') Then
                If $bRecursive Then ; Increse the FolderStack
                    If $sExclude <> '' And StringRegExp(StringRegExpReplace($sWorkingdir & '\' & $sFile, '(.*?[\\/]+)*(.*?\z)', '\2'), $sExclude) Then ContinueLoop
                    $aFolderStack[0] += 1
                    If UBound($aFolderStack) <= $aFolderStack[0] Then ReDim $aFolderStack[UBound($aFolderStack) * 1.5]
                    $aFolderStack[$aFolderStack[0]] = $sWorkingdir & '\' & $sFile
                EndIf
                If $iFlag <> 1 Then ; Add Folders
                    If Not $bRecursive And $sExclude <> '' And StringRegExp(StringRegExpReplace($sWorkingdir & '\' & $sFile, '(.*?[\\/]+)*(.*?\z)', '\2'), $sExclude) Then ContinueLoop
                    If Not StringRegExp($sFile, $sMask) Then ContinueLoop
                    $asFilelist &= $sWorkingdir & '\' & $sFile & $sDelim
                EndIf
            Else ; Add Files
                If $iFlag <> 2 Then
                    If Not StringRegExp($sFile, $sMask) Then ContinueLoop
                    If Not StringRegExp(StringRegExpReplace($sFilter, '^.*\.', ''), '[?*]') Then
                        If StringInStr($sFilter, StringRegExpReplace($sFile, '^.*\.', '')) = 0 Then ContinueLoop
                    EndIf
                    If $sExclude <> '' And StringRegExp(StringRegExpReplace($sWorkingdir & '\' & $sFile, '(.*?[\\/]+)*(.*?\z)', '\2'), $sExclude) Then ContinueLoop
                    $asFilelist &= $sWorkingdir & '\' & $sFile & $sDelim
                EndIf
            EndIf
        WEnd
        FileClose($hSearch)
    WEnd

    $asFilelist = StringTrimRight($asFilelist, 1)
    If StringLen($asFilelist) = 0 Then Return SetError(4, 4, '')
    If $iPathType = 0 Then $asFilelist = StringReplace($asFilelist, $sPath & '\', '')
    If $iRetFormat <> 0 Then $asFilelist = StringSplit($asFilelist, $sDelim, $iRetFormat)
    Return $asFilelist
EndFunc   ;==>_FileListToArrayEx
Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Oh right! Ian Max... well... :x Gotcha... So you're not going to use the SAD? :P Perhaps I'll add the code of FindHWIDS so we can collaborate!

Edited by kickarse

Share this post


Link to post
Share on other sites

Oh right! Ian Max... well... :x

HAHAHAHAHA

Gotcha... So you're not going to use the SAD? :P Perhaps I'll add the code of FindHWIDS so we can collaborate!

I would love to get some colab going, you have been coding INF parsers for a long time so you could no doubt add to things! Another area that REALLY needs help is driver installation natively - the current DeviceAPI works great for detection of local HWIDs but I have to rely on MS binaries to do the installation, which is a huge pain in everyone's "arse", so if we could get that going it would be HUGE!!! I found some info from MS here but I don't know how to implement it. Downloading the Windows Driver Kit is a lot to ask for folks to compile, and native would just be so SWEEEEET!!! :shifty:

Anything that can be done though, plese feel free!

Thanks

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

Hi Ian, thanks for your work on this tool.

I am using the script which you mentioned had help from Danny35d. I am having no success running this from a network share, either UNC or mapped to a drive letter which is unusual. I have tried with over 8 computers, using a combination of Windows XP, 2003, 7, which all get the messageBox popup 'Nothing to update', 'There are no drivers avaiable that are compatible with your computer.'

If I put this script and run from a CD or pen drive they all run and install the drivers fine.

Another thing that baffled me was when I deleted the HWIDrepository.sqlite (from a network path) and ran the DeviceInstall (from the network path), it created the sqlite database fine, but on the next run (to install the drivers) it always gives the Nothing to update error popup.

I hope you can revisit this script, even if only to fix the UNC compatability. I am also trying to determine why, but my guess is something to do with this section (I am not good at autoit)

_SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    For $a = 1 To $localHWID[0][0]
        $sDeviceName = $localHWID[$a][0]
        GUICtrlSetData($prog, $a / $localHWID[0][0] * 100)
        GUICtrlSetData($currentDeviceName, 'Device Name: ' & $sDeviceName)
        GUICtrlSetData($currentDeviceID, 'HWID: ' & $localHWID[$a][1])
        GUICtrlSetData($info, 'Looking for device driver matches')
        _SQLite_Exec($hDB1, "SELECT DISTINCT * FROM " & $TableDb & " WHERE hWId = '" & $localHWID[$a][1] & "';", "_InstallingDrivers")
    Next
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()

Appreciate it.

Share this post


Link to post
Share on other sites

Hi Ian, thanks for your work on this tool.

I am using the script which you mentioned had help from Danny35d. I am having no success running this from a network share, either UNC or mapped to a drive letter which is unusual. I have tried with over 8 computers, using a combination of Windows XP, 2003, 7, which all get the messageBox popup 'Nothing to update', 'There are no drivers avaiable that are compatible with your computer.'

If I put this script and run from a CD or pen drive they all run and install the drivers fine.

Another thing that baffled me was when I deleted the HWIDrepository.sqlite (from a network path) and ran the DeviceInstall (from the network path), it created the sqlite database fine, but on the next run (to install the drivers) it always gives the Nothing to update error popup.

I hope you can revisit this script, even if only to fix the UNC compatability. I am also trying to determine why, but my guess is something to do with this section (I am not good at autoit)

_SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    For $a = 1 To $localHWID[0][0]
        $sDeviceName = $localHWID[$a][0]
        GUICtrlSetData($prog, $a / $localHWID[0][0] * 100)
        GUICtrlSetData($currentDeviceName, 'Device Name: ' & $sDeviceName)
        GUICtrlSetData($currentDeviceID, 'HWID: ' & $localHWID[$a][1])
        GUICtrlSetData($info, 'Looking for device driver matches')
        _SQLite_Exec($hDB1, "SELECT DISTINCT * FROM " & $TableDb & " WHERE hWId = '" & $localHWID[$a][1] & "';", "_InstallingDrivers")
    Next
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()

Appreciate it.

Hi, thanks for the message and I am glad the tool has helped you somewhat.

This issue has not yet been brought up in this thread so I am not at all surprised that you weren't aware of the network issue, sorry about that! The issue is that the DeviceAPI.au3 written by weaponx does not work over network sources, it must be run locally. There is nothing I can do to get around the issue, but one thought (untested) would be for you to create a mapped drive so it THINKS it is running locally. AutoIt even has some UDFs that you can use to automate that process, so maybe consider writing your own wrapper that would create the mapped drive and then execute this script.

Worth a shot...... :)

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

Hi, thanks for the message and I am glad the tool has helped you somewhat.

This issue has not yet been brought up in this thread so I am not at all surprised that you weren't aware of the network issue, sorry about that! The issue is that the DeviceAPI.au3 written by weaponx does not work over network sources, it must be run locally. There is nothing I can do to get around the issue, but one thought (untested) would be for you to create a mapped drive so it THINKS it is running locally. AutoIt even has some UDFs that you can use to automate that process, so maybe consider writing your own wrapper that would create the mapped drive and then execute this script.

Worth a shot...... :)

Ian

Ah yes, I forgot to mention that in my tests as above I also tried mapping network drives first which suprisingly did not work either. So I guess USB or DVD installation will be the way to go for now.

Share this post


Link to post
Share on other sites

So I'll be going through my code to figure out how to improve it and help you out... give me about a week... I'll post some code examples shortly.

Share this post


Link to post
Share on other sites

So I'll be going through my code to figure out how to improve it and help you out... give me about a week... I'll post some code examples shortly.

Hey Ian hows it going? Any progress?

We are rolling out a new sysprep system at work and I have a few options. One would be to use driverpacks and integrate the lot into our sysprep using dism, but would add a few gigs that will be rolled out to all machines. I would then use some kind of software (if it exists) to strip out unused drivers perhaps? to save space.. dunno if thats possible, otherwise I could use driverinstaller to install from a %temp% folder or even better from a samba share.

Life is keeping you busy Im sure.. Some time I would like to pick your brain about your Imaging solutions, at the moment we use ghost and push/pull images of hardware types with no syspreping since noone here knows how to sysprep including myself lol

Thanks

Share this post


Link to post
Share on other sites

Give it a try:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Include\Icon_1.ico
#AutoIt3Wrapper_outfile=NewInfSniff.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~  DriverPacks.net HWID extractor
;~  AKA
;~  INFSniff

;~  Coded by Ian Maxwell (llewxam @ www.driverpacks.net & www.autoitscript.com forums)
;~  AutoIt 3.3.6.1
;~  Folder recursion routine by weaponx @ www.autoitscript.com forum
;~ Windows build number http://en.wikipedia.org/wiki/Windows_NT

#NoTrayIcon
#RequireAdmin

#include <File.au3>
#include <Array.au3>
#include <SQLite.au3>
#include <DeviceAPI.au3>
#include <sqlite.dll.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

FileInstall('.\Include\7z.exe', @TempDir & '\', 1)
FileInstall('.\Include\7z.dll', @TempDir & '\', 1)

Global $TableDb = 'Nt5'
Global $sDeviceName
Global $showInstalled, $info
Global $ScriptDirEx = @ScriptDir
Global $TempFolder = _TempFile(@TempDir, '', '')
Global $AppLog = StringTrimRight(@ScriptFullPath, 3) & 'Log'
Global $DriversDBFullPath = @ScriptDir & '\HWIDrepository.sqlite'

If DriveGetType($ScriptDirEx) = 'Network' Then
    FileCopy(@ScriptFullPath, @TempDir, 9)
    If @Compiled Then
        Run('"' & @TempDir & '\' & @ScriptName & '" "' & $AppLog & '" "' & $DriversDBFullPath & '" "' & $ScriptDirEx & '"', @ScriptDir)
    Else
        FileCopy(@ScriptDir & '\' & 'DeviceAPI.au3', @TempDir, 9)
        Run(@AutoItExe & ' "' & @TempDir & '\' & @ScriptName & '" "' & $AppLog & '" "' & $DriversDBFullPath & '" "' & $ScriptDirEx & '"', @ScriptDir)
    EndIf
    Exit
EndIf

If $CMDLine[0] > 0 Then
    $AppLog = $CMDLine[1]
    $DriversDBFullPath = $CMDLine[2]
    $ScriptDirEx = $CMDLine[3]
EndIf

If FileExists($AppLog) Then FileDelete($AppLog)
If Not FileExists($DriversDBFullPath) Then
    $Rtn = _CreateHwidList()
    $sTitle = 'Done'
    $sMsg = 'Finished sniffing the INFs, the output has been saved to:' & @CR & $DriversDBFullPath
    If $Rtn Then
        FileDelete($DriversDBFullPath)
        $sTitle = 'Warning...'
        $sMsg = 'Failed to create database, please check log: ' & @CRLF & $AppLog
    EndIf
    MsgBox(0, $sTitle, $sMsg)
Else
    If @OSBuild <= 2195 Then ;Windows 2000 and below are unsupported OSes
        $sTitle = 'Unsupported OS'
        $sMsg = 'Due to API issues, Windows ' & StringReplace(@OSVersion, 'win_', '') & ' is not supported at this time.'
    Else
        _SearchingDB()
    EndIf
EndIf

FileDelete(@TempDir & '\' & @ScriptName)
FileDelete(@TempDir & '\DeviceAPI.au3')
FileDelete(@TempDir & '\7z.*')
Exit

Func _SearchingDB()
    Dim $localHWID[1][2]

    If @OSBuild > 3790 Then $TableDb = 'Nt6' & @OSArch
    ;Build list of devices
    _DeviceAPI_GetClassDevices()
    While _DeviceAPI_EnumDevices()
        $haveHWID = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID)
        If $haveHWID <> '' Then
            ReDim $localHWID[UBound($localHWID) + 1][2]
            $generic = $haveHWID  ;_DeviceAPI_GetDeviceRegistryProperty($SPDRP_HARDWAREID)
            If StringInStr($generic, 'SUBSYS') Then
                $break = StringSplit($generic, 'SUBSYS', 1)
                $generic = StringTrimRight($break[1], 1)
;~              $specific = $break[2] ; Not used, but could be to further refine the results
            EndIf
            $localHWID[UBound($localHWID) - 1][0] = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_DEVICEDESC)
            $localHWID[UBound($localHWID) - 1][1] = $generic
        EndIf
    WEnd
    $localHWID[0][0] = UBound($localHWID) - 1

    FileInstall('.\Include\dpinst.xml', @TempDir & '\dpinst.xml', 1)
    If @OSArch = 'X86' Then FileInstall('.\Include\dpinst.exe', @TempDir & '\', 1)
    If @OSArch = 'X64' Then FileInstall('.\Include\dpinst64.exe', @TempDir & '\dpinst.exe', 1)

    $GUIWidth = @DesktopWidth - 100
    $main = GUICreate('Driver Installer v2 - MaxImuM AdVaNtAgE SofTWarE © 2010', $GUIWidth, 173, 50, 10, $WS_CLIPSIBLINGS)
    $currentDeviceName = GUICtrlCreateLabel('', 5, 5, $GUIWidth - 10, 20)
    $currentDeviceID = GUICtrlCreateLabel('', 5, 25, $GUIWidth - 10, 20, $SS_NOPREFIX)
    $info = GUICtrlCreateLabel('', 5, 65, $GUIWidth - 10, 40)
    $prog = GUICtrlCreateProgress(2, 120, $GUIWidth - 10, 20)
    GUISetState()

    _SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    For $a = 1 To $localHWID[0][0]
        $sDeviceName = $localHWID[$a][0]
        GUICtrlSetData($prog, $a / $localHWID[0][0] * 100)
        GUICtrlSetData($currentDeviceName, 'Device Name: ' & $sDeviceName)
        GUICtrlSetData($currentDeviceID, 'HWID: ' & $localHWID[$a][1])
        GUICtrlSetData($info, 'Looking for device driver matches')
        _SQLite_Exec($hDB1, "SELECT DISTINCT * FROM " & $TableDb & " WHERE hWId = '" & $localHWID[$a][1] & "';", "_InstallingDrivers")
    Next
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()

    If $showInstalled <> '' Then $showInstalled = StringSplit(StringTrimRight($showInstalled, 1), '|')
    GUIDelete($main)
    If IsArray($showInstalled) Then
        $showGUI = GUICreate('Installed Drivers', 600, 200, 1, 1)
        $showList = GUICtrlCreateList('', 5, 5, 590, 190)
        GUISetState(@SW_SHOW, $showGUI)

        For $a = 1 To $showInstalled[0]
            GUICtrlSetData($showList, $showInstalled[$a])
        Next
        Do
            $iMsg = GUIGetMsg()
            Sleep(50)
        Until $iMsg = $GUI_EVENT_CLOSE
    Else
        MsgBox(0, 'Nothing to update', 'There are no drivers avaiable that are compatible with your computer.')
    EndIf

    DirRemove($TempFolder, 1)
    FileDelete(@TempDir & '\dpinst.xml')
    FileDelete(@TempDir & '\dpinst.exe')
EndFunc   ;==>_SearchingDB

Func _InstallingDrivers($aRow)
    If Not StringInStr($showInstalled, $sDeviceName) Then $showInstalled &= $sDeviceName & '|'
    GUICtrlSetData($info, 'Found match, extracting ' & $aRow[2] & ' from ' & $aRow[1])
    $Rtn = RunWait(@TempDir & '\7z.exe x "' & $ScriptDirEx & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\* -r -y -x!*.inf', @TempDir, @SW_HIDE) ;extract the current driver from the DriverPack
    _FileWriteLog($AppLog, _7zipExitCode($Rtn) & '\7z.exe x "' & $ScriptDirEx & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\* -r -y -x!*.inf')
    $Rtn = RunWait(@TempDir & '\7z.exe x "' & $ScriptDirEx & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\' & $aRow[3] & ' -y', @TempDir, @SW_HIDE) ;extract the current driver from the DriverPack
    _FileWriteLog($AppLog, _7zipExitCode($Rtn) & '\7z.exe x "' & $ScriptDirEx & '\' & $TableDb & '\' & $aRow[1] & '" -o"' & $TempFolder & '" ' & $aRow[2] & '\' & $aRow[3] & ' -y')

    If $Rtn <> 0 Then
        GUICtrlSetData($info, 'Failed to unzip drivers.')
    Else
        GUICtrlSetData($info, 'Installing driver.')
        $Rtn = ShellExecuteWait(@TempDir & '\dpinst.exe', '/S /SA /SE /SW /PATH "' & $TempFolder & '\' & $aRow[2] & '"')
        _FileWriteLog($AppLog, 'ExitCode: ' & $Rtn & ' ' & 'dpinst.exe /S /SA /SE /SW /PATH "' & $TempFolder & '\' & $aRow[2] & '"' & @CRLF)
    EndIf
    DirRemove($TempFolder, 1)
EndFunc   ;==>_InstallingDrivers

Func _CreateHwidList()
    Local $HWIDsplit, $DP, $ExitCodeError = False
    Dim $DriversPath[3] = [$ScriptDirEx & '\Nt5', $ScriptDirEx & '\Nt6x64', $ScriptDirEx & '\Nt6x86']

    For $Path In $DriversPath
        If FileExists($Path) Then $DP &= FLwStr($Path, '(?i)\.7z\z', 1, 0, 0)
    Next
    If $DP <> '' Then $DP = StringSplit(StringTrimRight($DP, 1), '|')
    If Not IsArray($DP) Then
        MsgBox(48, 'Warning', "Didn't found any Driver Packs 7z files.")
        Exit
    EndIf

    $showProg = GUICreate('INFSniff - MaxImuM AdVaNtAgE SofTWarE © 2010', 600, 100, -1, -1, $WS_CLIPSIBLINGS)
    $showCurrentName = GUICtrlCreateLabel('', 5, 5, 590, 50, $SS_CENTER)
    $prog = GUICtrlCreateProgress(2, 48, 590, 20)
    GUISetState(@SW_SHOW, $showProg)

    _SQLite_Startup()
    $hDB1 = _SQLite_Open($DriversDBFullPath)
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt5 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt6x64 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'CREATE TABLE IF NOT EXISTS Nt6x86 (hWId TEXT, FileName TEXT, FolderName TEXT, InfFileName TEXT);')
    _SQLite_Exec($hDB1, 'begin;')

    For $x = 1 To $DP[0]
        DirCreate($TempFolder)
        GUICtrlSetData($prog, Int($x / $DP[0] * 100))
        GUICtrlSetData($showCurrentName, 'Please wait, extracting INFs from ' & $DP[$x])
        $Rtn = RunWait(@TempDir & "\7z.exe x " & Chr(34) & $DP[$x] & Chr(34) & " -o" & Chr(34) & $TempFolder & Chr(34) & " *.inf -r -y", @TempDir, @SW_HIDE)
        _FileWriteLog($AppLog, _7zipExitCode($Rtn) & "7z.exe x " & Chr(34) & $DP[$x] & Chr(34) & " -o" & Chr(34) & $TempFolder & Chr(34) & " *.inf -r -y")
        If $Rtn <> 0 Then
            $ExitCodeError = True
            ContinueLoop
        EndIf

        $INFList = FLwStr($TempFolder, '(?i)\.inf\z', 1, 1, 1)
        $TableToRecord = StringReplace(StringRegExpReplace($DP[$x], "^(.*)\\.*?$", "${1}"), $ScriptDirEx & '\', '')
        If IsArray($INFList) Then
            For $a = 1 To $INFList[0]
                $FileName = StringRegExpReplace($DP[$x], '^.*\\', '')
                $InfFileName = StringRegExpReplace($INFList[$a], '^.*\\', '')
                $FolderName = StringRegExpReplace(StringReplace($INFList[$a], $TempFolder & '\', ''), "^(.*)\\.*?$", "${1}")
                GUICtrlSetData($showCurrentName, 'Please wait, proccessing INFs ' & $INFList[$a])
                $man = IniReadSection($INFList[$a], 'Manufacturer')
                If @error Then ContinueLoop
                For $b = 1 To $man[0][0]
                    $manBreak = StringSplit($man[$b][1], ',')
                    For $c = 1 To $manBreak[0]
                        If $c = 1 Then
                            $indivMan = StringStripWS($manBreak[$c], 8)
                        Else
                            $indivMan = StringStripWS($manBreak[1] & '.' & $manBreak[$c], 8)
                        EndIf
                        $HWID = IniReadSection($INFList[$a], $indivMan)
                        If @error Then ContinueLoop
                        For $d = 1 To $HWID[0][0]
                            If StringInStr($HWID[$d][1], ',') = 0 And StringInStr($HWID[$d][1], '\') <> 0 Then
                                If StringInStr($HWID[$d][1], ';') Then
                                    $semiTrim = StringSplit($HWID[$d][1], ';')
                                    _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($semiTrim[1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                Else
                                    _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($HWID[$d][1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                EndIf
                            EndIf
                            If StringInStr($HWID[$d][1], ',') Then
                                $HWIDsplit = StringSplit($HWID[$d][1], ',')
                                For $l = 1 To $HWIDsplit[0]
                                    If StringInStr($HWIDsplit[$l], '\') Then
                                        If StringInStr($HWIDsplit[$l], ';') Then
                                            $semiTrim = StringSplit($HWIDsplit[$l], ';')
                                            _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($semiTrim[1], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                        Else
                                            _SQLite_Exec($hDB1, "Insert into " & $TableToRecord & " values ('" & StringStripWS($HWIDsplit[$l], 8) & "', '" & $FileName & "', '" & $FolderName & "', '" & $InfFileName & "');")
                                        EndIf
                                    EndIf
                                Next
                            EndIf
                        Next
                    Next
                Next
            Next
        EndIf
        DirRemove($TempFolder, 1)
    Next

    _SQLite_Exec($hDB1, 'commit;')
    GUIDelete($showProg)
    _SQLite_Close($hDB1)
    _SQLite_Shutdown()
    Return ($ExitCodeError)
EndFunc   ;==>_CreateHwidList

Func _7zipExitCode($iExitCode)
    Switch $iExitCode
        Case 0
            $msg = 'Sucessfull : '
        Case 1
            $msg = 'Warning(Non fatal error(s)): '
        Case 2
            $msg = 'Fatal error: '
        Case 7
            $msg = 'Command line error: '
        Case 8
            $msg = 'Not enough memory for operation: '
        Case 255
            $msg = 'User stopped the process: '
        Case Else
            $msg = 'Unknown error: '
    EndSwitch
    Return ($msg)
EndFunc   ;==>_7zipExitCode

; #FUNCTION# ======================================================================================
; Name ..........: FLwStr()
; Description ...: Finding files and / or folders in a directory tree
; Syntax ........: FLwStr($sSD, Const[ $sPat = '', Const[ $iF = 3]])
; Parameters ....: $sSD           - Search location (multiple search locations by | separate)
;                  Const $sPat    - [optional] regular expression to find the file / folder name (default: '')
;                  Const $iF      - [optional] 1 = only files, 2 = only folders, 3 = files & folder (default: 3)
;                  Const $iSSFlag - [optional] 0 = String ( "|" delimited), 1 = one-dimensional array, 1-based, 2 = one-dimensional array, 0-based
;                  Const $iIterative - 0 = (Default) Search in specified directory, 1 = Search in specified and all subdirectories.
; Return values .: Success - Return Array with Matches with $Array[0] = Count & @error = 0
;                  Failure - Return "" and set @error = 1
;                  @Extended
;                    1 = Path not found or invalid
;                    2 = Invalid $iF
;                    3 = Invalid $iSSFlag
;                    4 = Invalid $iIterative
;                    5 = No File(s) or Folder(s) Found
; Author ........: AspirinJunkie
; Remarks .......: Operation is iterative - not recursive
; Example .......: Yes
;                  #include <Array.au3>
;                  $aTmp = FLwStr(@WindowsDir & '|' & @ProgramFilesDir, "^Temp$", 2)
;                  _ArrayDisplay($aTmp)
; =================================================================================================
Func FLwStr($sSD, $sPat = '', $iF = 3, $iSSFlag = 0, $iIterative = 1)
    Local $sRetFiles, $sRetFolders, $sRet, $sSubD
    Local $FFFF, $FFNF, $sDir, $iC, $aD, $hDLL = DllOpen('kernel32.dll')

    For $i In StringSplit($sSD, '|', 2)
        If StringRight($i, 1) = '\' Then $i = StringTrimRight($i, 1)
        If Not FileExists($i) Then Return SetError(1, 1, '')
        $sSubD &= '|' & $i
    Next
    If Not StringRegExp($iF, '[123]') Then Return SetError(1, 2, '')
    If Not StringRegExp($iSSFlag, '[012]') Then Return SetError(1, 3, '')
    If Not StringRegExp($iIterative, '[01]') Then Return SetError(1, 4, '')
    Do
        $iC = StringInStr($sSubD, '|', 2, -1)
        If @error Or $iC = 0 Then ExitLoop
        $iC = StringLen($sSubD) - $iC
        $sDir = StringRight($sSubD, $iC)
        $sSubD = StringTrimRight($sSubD, $iC + 1)
        $FFFF = FileFindFirstFile($sDir & '\*')
        If $FFFF <> -1 Then
            Do
                $FFNF = FileFindNextFile($FFFF)
                If @error Then ExitLoop
                If @extended Then
                    If BitAND(StringRegExp($FFNF, $sPat) * 2, $iF) Then $sRetFolders &= $sDir & '\' & $FFNF & '|'
                    $aD = DllCall($hDLL, 'dword', 'GetFileAttributesW', 'wstr', $sDir & '\' & $FFNF)
                    If @error Or BitAND($aD[0], 0x400) Then ContinueLoop
                    If $iIterative Then $sSubD &= '|' & $sDir & '\' & $FFNF
                ElseIf BitAND(StringRegExp($FFNF, $sPat), $iF) Then
                    $sRetFiles &= $sDir & '\' & $FFNF & '|'
                EndIf
            Until 0
            FileClose($FFFF)
        EndIf
    Until 0
    DllClose($hDLL)
    $sRet = $sRetFolders & $sRetFiles
    If $sRet = '' Then Return SetError(1, 5, '')
    If $iSSFlag <> 0 Then $sRet = StringSplit(StringTrimRight($sRet, 1), '|', $iSSFlag)
    Return SetError(0, 0, $sRet)
EndFunc   ;==>FLwStr

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Give it a try:

LOL, I see what you did... sneaky bugger!! :>

Very nice solution, I only tested it on my machine though so will try it out a few times at work tomorrow. Storme has also been waiting (patiently :unsure: ) for a long time to get an update module he wrote included, but I was dragging my feet in case kickarse came through with some code as well. I will stop delaying and get a GUI for that assembled soon and bundle it all together.

Thanks again, this might make for a very interesting tweak to the universal imaging as well, as currently my images have the drivers as part of the image so are on the local machine, but now it could just specify a network source and save that space from the image, therefore also reducing time to deploy the images over the network.

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

Storme has also been waiting (patiently :unsure: ) for a long time to get an update module he wrote included, but I was dragging my feet in case kickarse came through with some code as well. I will stop delaying and get a GUI for that assembled soon and bundle it all together.

Hmm "patiently"...... well maybe quietly :> LOL

It'd be great to see an integrated GUI.

Something that I've run into recently is the need to load ONLY ONE driver (lan card) without loading everything else (there was a conflict wiht the latest version of another driver). Is there any chance of putting that functionality into the program?

OR

Maybe just extracting the drivers for the computer to some location and alowing the user to install what they want?

Just some thoughts. You know of full of it...ahh I mean them ;)

Storm-E

AKA

John Morrison

Share this post


Link to post
Share on other sites

Hmm "patiently"...... well maybe quietly :unsure: LOL

hehehe, you only asked about it a few times, I would have done the same.

Something that I've run into recently is the need to load ONLY ONE driver (lan card) without loading everything else (there was a conflict wiht the latest version of another driver). Is there any chance of putting that functionality into the program?

Definitely, I have wanted the same thing many times! I am picturing a GUI that has a countdown of maybe 10 seconds, and if nothing is selected by then than all drivers are loaded. I would put in a checkbox for each class type. I would rather get it out of the way before the ball got rolling, rather than having to choose after the scan is done.

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

hehehe, you only asked about it a few times, I would have done the same.

Definitely, I have wanted the same thing many times! I am picturing a GUI that has a countdown of maybe 10 seconds, and if nothing is selected by then than all drivers are loaded. I would put in a checkbox for each class type. I would rather get it out of the way before the ball got rolling, rather than having to choose after the scan is done.

Ian

Yes! I would also like to see that in your tool. I have been using your tool a lot; very useful and time-saving, but have never had the time to delve into into it and tweak.

Looking forward to the update.

Thanks again for this wonderful tool. My colleagues love it too.... has kinda made them lazy.

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  
Followers 0