Deployment Solution

 View Only

HII Tools Driver Library Maintenance 

Nov 27, 2007 11:27 AM

Now that you have installed HII Tools 3.2 and are using the "Collect Drivers" job as well as the "Manual Add Drivers" method to populate your driver library, you probably will want to know how to maintain your library. I am working on a console add-on similar to my HII Job Wizard that will help you perform Driver Library Maintenance tasks. In the meantime, this document will explain how to do each of the maintenance tasks manually. If you think of any Driver Library Maintenance procedure that you would like that is not in this document, make a comment describing what you would like.

This document will explain how to perform the following Driver Library Maintenance tasks:

  1. Driver Library cleanup
  2. Export (backup) the Driver Library
  3. Import (restore) the Driver Library
  4. Add an Installer for a particular driver in the library
  5. Automatically run the Collect Drivers job against computers with new devices

Driver Library cleanup

Driver Library cleanup is simple. All you need to do is run "Update Driver Database.bat" that will start the cleanup process. This will automatically discover which drivers will never be selected as the best driver for any Device/OS combination and will remove the useless drivers.

Export (backup) the Driver Library

Once you have done all the work to populate your Driver Library, you will want to export it as a backup.

Before you export your Driver Library, you probably will want to perform a Driver Library Cleanup to minimize its size.

The export process is very simple. All you need to do is compress the HII\Drivers folder into an archive format of your choice. My preference is to use 7-zip to create a .7z file; it has the best compression ratio and has never let me down.

The console add-on will likely export the library into a ".7z" file with a compression level of your choice that has been renamed to have the extension ".dla" (Driver Library Archive).

Import (restore) the Driver Library

After you have exported your Driver Library, you can import the drivers to this server again in case of data loss, or you can import the drivers into any other Deployment Server's Driver Library. You could even create a Driver Library replication job if you manage multiple Deployment Servers.

There are 2 steps to import your Driver Library Archive.

  1. Extract your archive file into the HII\Drivers folder, replacing older files.
  2. Run "Update Driver Database.bat"

If you want to replicate the Driver Library from one Deployment Server to another without compressing it to an archive first, simply copy the HII\Drivers folder from one server to the other and then run "Update Driver Database.bat" on the destination server.

Add an Installer for a particular driver in the library

When it is possible, it is best to use drivers that do not require an application to install. However, sometimes you will need to provide an installer application for certain drivers. To do this, you will need to do # things.

  1. Perform a Driver Library cleanup to get rid of the useless drivers so that it will be easier to find the driver you want to update
  2. Find the Hardware ID of the device you want to update the driver for. Future versions of HII Tools will display the device name in the database. In the meantime, you will need to do the following.
    1. Go to the Device Manager of a computer with this device.
    2. Double-click the device.
    3. Go to the Details tab.
    4. In the drop-down list, choose Hardware Ids
    5. Keep this list up for reference in the next step
  3. Find the Driver ID of the driver you want to update.
    1. Open SQL Query Analyzer
    2. In the database drop-down list, select your Deployment Server Database
    3. Cut-and-paste the following query into the Query Window
      SELECT * FROM hii_device WHERE hardware_id LIKE '%VEN_0000&DEV_1111%' ORDER BY driver_id
      
      
    4. Replace "0000" with the Vendor Number and replace "1111" with the Device Number. You can provide a more specific Hardware ID, but this should be sufficient.
    5. You will see a list of Driver IDs along with the OS that they are compatible with. If you see multiple Driver IDs listed, find the one that most closely matches. The OS Versions are: 2000=5.0, XP=5.1, 2003=5.2, Vista=6.0
  4. In Windows Explorer, go to the HII\Drivers folder and open the folder that matches the Device ID of the Driver you want to update.
  5. Copy the Driver Installer files into the driver folder.
  6. Create a file named instdrvr.bat in the driver folder containing the silent install command for the Driver Install Application.
  7. Open the Deployment Console.
  8. Go to your Distribute Hardware Independent Image Job.
  9. Modify the "Copy Drivers and HAL" Run Script task.
  10. Add
    "echo "FOR /D %%i IN ("%%SystemDrive%%\Drivers\*.*") DO (call %%i\instdrvr.bat)
    ">>%ProductionDrive%\Sysprep\i386\$OEM$\cmdlines.txt"
    
    
    after the following:
    REM rescan all devices
    echo "devcon rescan">>%ProductionDrive%\Sysprep\i386\$OEM$\cmdlines.txt
    
    
    1. Replace "Drivers" with the actual location of your drivers on the destination computer

Automatically run the Collect Drivers job against computers with new devices

In order to automatically collect new drivers, you will need to create a SQL Trigger that will schedule your Collect Drivers job whenever a new device is added to the devices table in the database.

  1. Open SQL Query Analyzer
  2. In the database drop-down list, select your Deployment Server Database
  3. Find the Event ID of the Collect Drivers job
    1. Run the SQL Query "SELECT event_id FROM event WHERE name = 'Collect Drivers'" (replace "Collect Drivers" with the actual name of your Collect Drivers job)
  4. Find the SQL Query from the following that matches the schedule you want to automatically run Collect Driver on. Modify it, updating the "--User Defined Variables" section with the Event ID of your Collect Drivers job and time to run the job if applicable, and then run the Query.
    1. Run Collect Drivers job now.
      
      IF EXISTS (SELECT name FROM sysobjects WHERE name = 'device_schedule_collect_drivers' AND type = 'TR')
          DROP TRIGGER device_schedule_collect_drivers
      GO
      
      CREATE TRIGGER device_schedule_collect_drivers ON device FOR INSERT, UPDATE
      AS
      DECLARE @event_id int
      DECLARE @computer_id int
      DECLARE @start_time datetime
      --User Defined Variables
      SET @event_id = 0000000
      --End User Defined Variables
      SELECT @computer_id=computer_id FROM inserted
      SELECT @start_time=GETDATE()
      IF (SELECT COUNT(1) FROM device WHERE manuf + name NOT IN (SELECT manuf + name FROM inserted)) = 0
          EXEC mm_schedule_event @event_id, @computer_id, @start_time, 'New device(s) found, job automatically scheduled', 0, 0, 0, 0, 0
      GO
      
      
    2. Run Collect Drivers job n minutes from now.
      IF EXISTS (SELECT name FROM sysobjects WHERE name = 'device_schedule_collect_drivers' AND type = 'TR')
          DROP TRIGGER device_schedule_collect_drivers
      GO
      
      CREATE TRIGGER device_schedule_collect_drivers ON device FOR INSERT, UPDATE
      AS
      DECLARE @event_id int
      DECLARE @minute int
      DECLARE @computer_id int
      DECLARE @start_time datetime
      --User Defined Variables
      SET @event_id = 0000000
      SET @minute = 750
      --End User Defined Variables
      SELECT @computer_id=computer_id FROM inserted
      SELECT @start_time=DATEADD(minute, @minute, GETDATE())
      IF (SELECT COUNT(1) FROM device WHERE manuf + name NOT IN (SELECT manuf + name FROM inserted)) = 0
          EXEC mm_schedule_event @event_id, @computer_id, @start_time, 'New device(s) found, job automatically scheduled', 0, 0, 0, 0, 0
      GO
      
      
    3. Schedule the job at a particular time of day. Modify the @minute variable to the time you want to schedule the job in number of minutes from midnight.
      IF EXISTS (SELECT name FROM sysobjects WHERE name = 'device_schedule_collect_drivers' AND type = 'TR')
          DROP TRIGGER device_schedule_collect_drivers
      GO
      
      CREATE TRIGGER device_schedule_collect_drivers ON device FOR INSERT, UPDATE
      AS
      DECLARE @event_id int
      DECLARE @minute int
      DECLARE @computer_id int
      DECLARE @start_time datetime
      --User Defined Variables
      SET @event_id = 0000000
      SET @minute = 750
      --End User Defined Variables
      SELECT @computer_id=computer_id FROM inserted
      IF ((DATEPART(hour, GETDATE()) * 60) + (DATEPART(minute, GETDATE()))) > @minute
          SELECT @start_time=DATEADD(minute, @minute, DATEADD(day, 1, DATEDIFF(day, 0, GETDATE())))
      ELSE
          SELECT @start_time=DATEADD(minute, @minute, DATEADD(day, 0, DATEDIFF(day, 0, GETDATE())))
      IF (SELECT COUNT(1) FROM device WHERE manuf + name NOT IN (SELECT manuf + name FROM inserted)) = 0
          EXEC mm_schedule_event @event_id, @computer_id, @start_time, 'New device(s) found, job automatically scheduled', 0, 0, 0, 0, 0
      GO
      
      
    4. Schedule the job at a particular time on a particular day of the week. @minute is number of minutes from midnight.
      @week_day is the day of the week, Sunday (1) through Saturday (7).
      IF EXISTS (SELECT name FROM sysobjects WHERE name = 'device_schedule_collect_drivers' AND type = 'TR')
          DROP TRIGGER device_schedule_collect_drivers
      GO
      
      CREATE TRIGGER device_schedule_collect_drivers ON device FOR INSERT, UPDATE
      AS
      DECLARE @event_id int
      DECLARE @minute int
      DECLARE @week_day int
      DECLARE @computer_id int
      DECLARE @start_time datetime
      --User Defined Variables
      SET @event_id = 0000000
      SET @minute = 750
      SET @week_day = 7
      --End User Defined Variables
      SELECT @computer_id=computer_id FROM inserted
      IF ((DATEPART(weekday, GETDATE())) > @week_day) OR (((DATEPART(weekday, GETDATE())) = @week_day) AND (((DATEPART(hour, GETDATE()) * 60) + (DATEPART(minute, GETDATE()))) > @minute))
          SELECT @start_time=DATEADD(minute, @minute, DATEADD(day, (7 + @week_day) - DATEPART(weekday, GETDATE()), DATEDIFF(day, 0, GETDATE())))
      ELSE
          SELECT @start_time=DATEADD(minute, @minute, DATEADD(day, @week_day - DATEPART(weekday, GETDATE()), DATEDIFF(day, 0, GETDATE())))
      IF (SELECT COUNT(1) FROM device WHERE manuf + name NOT IN (SELECT manuf + name FROM inserted)) = 0
          EXEC mm_schedule_event @event_id, @computer_id, @start_time, 'New device(s) found, job automatically scheduled', 0, 0, 0, 0, 0
      GO
      
      

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
doc file
HII Tools Driver Library Maintenance.doc   86 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Comments

Apr 02, 2010 06:40 PM


great article

Feb 13, 2009 09:40 PM

Hmmm. I tried using SQL Express Manager to open dbo.hii_device and then run a SQL query manually for "EXEC hii_delete_inactive_drivers" and get the following message.
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'hii_delete_inactive_drivers'.
Any ideas by chance?

Feb 13, 2009 08:07 PM

Thanks again Condor.
Question though, when I run the batch file to Update the Database I get the following when I parse the log. How do I fix hii_delete_inactive_drivers?
"Beginning Driver CleanUp. Destination: F:\eXpress\HII\Drivers
Deleting inactive drivers from the database
Executing SQL command: EXEC hii_delete_inactive_drivers
Exception while deleting inactive drivers from the database: ERROR [42000] [Micr
osoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'hii_d
elete_inactive_drivers'.
Getting a list of active drivers from the database
Executing SQL command: EXEC hii_get_driver '*', '*'
Searching F:\eXpress\HII\Drivers for inactive drivers
Updating database with cleanup completion datetime.
Executing SQL command: IF NOT EXISTS (SELECT 1 FROM hii_settings)
INSERT INTO hii_settings (CollectStatus, AutoCollectMode, AutoCollectJob, Au
toCollectDay, AutoCollectHour, AutoCollectMinute, AutoCollectPM) VALUES (0, 0, 0
, 1, 1, 0, 0)
Executing SQL command: UPDATE hii_settings SET CleanLastRun='2/13/2009 7:02:06 P
M'
Exception while updating database with cleanup completion datetime: ERROR [42S22
] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'CleanLastR
un'.
Driver CleanUp has completed
Updating database with Driver Collect status.
Executing SQL command: IF NOT EXISTS (SELECT 1 FROM hii_settings)
INSERT INTO hii_settings (CollectStatus, AutoCollectMode, AutoCollectJob, Au
toCollectDay, AutoCollectHour, AutoCollectMinute, AutoCollectPM) VALUES (0, 0, 0
, 1, 1, 0, 0)
Executing SQL command: UPDATE hii_settings SET CollectStatus=100"

Nov 27, 2007 12:41 PM

Good article CondorMan, well decribed , interesting and helpful.

Related Entries and Links

No Related Resource entered.