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:
- Driver Library cleanup
- Export (backup) the Driver Library
- Import (restore) the Driver Library
- Add an Installer for a particular driver in the library
- 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.
- Extract your archive file into the HII\Drivers folder, replacing older files.
- 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.
- 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
- 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.
- Go to the Device Manager of a computer with this device.
- Double-click the device.
- Go to the Details tab.
- In the drop-down list, choose Hardware Ids
- Keep this list up for reference in the next step
- Find the Driver ID of the driver you want to update.
- Open SQL Query Analyzer
- In the database drop-down list, select your Deployment Server Database
- 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
- 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.
- 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
- 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.
- Copy the Driver Installer files into the driver folder.
- Create a file named instdrvr.bat in the driver folder containing the silent install command for the Driver Install Application.
- Open the Deployment Console.
- Go to your Distribute Hardware Independent Image Job.
- Modify the "Copy Drivers and HAL" Run Script task.
- 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
- 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.
- Open SQL Query Analyzer
- In the database drop-down list, select your Deployment Server Database
- Find the Event ID of the Collect Drivers job
- 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)
- 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.
- 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
- 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
- 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
- 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