Windows 7 Install Unsigned Drivers Remotely

From richud.com
Jump to navigation Jump to search

Please first [this]

core files

I have found the simplest way to do this is have a folder like this (dpinst64.exe is renamed 64bit dpinst.exe)

├── CertMgr.Exe
├── dpinst64.exe
├── dpinst.xml
└── drop-all-to-driver-folder-and-run-this.bat

Copy the contents into the driver's folder, then run "drop-all-to-driver-folder-and-run-this.bat" file (from a machine that has access to the target machine. This copies everything into the targets temp folder and executes it.

  • Note, The richud.com.cer self-signed certificate is assumed to be in the drivers folder already.

drop-all-to-driver-folder-and-run-this.bat

@echo off
echo          _       __              __                     
echo    _____(_)_____/ /_  __  ______/ / _________  ____ ___ 
echo   / ___/ // ___/ __ \/ / / / __  / / ___/ __ \/ __ `__ \
echo  / /  / // /__/ / / / /_/ / /_/ /_/ /__/ /_/ / / / / / /
echo /_/  /_/ \___/_/ /_/\__,_/\__,_/(_)___/\____/_/ /_/ /_/ 
echo.
echo Remote Driver Installer
echo ---=== Last updated 12/Jun/2012 ===---
echo.

if [%1%] == [] (
 set /p h=Enter Hostname or IP :
) ELSE (
 set h=%1%
)

echo Ping testing %h%...
ping -n 2 -l 1 %h% >nul
if %errorlevel% neq 0 set f=Cannot ping host & goto fail
echo RPC testing %h%...
net use \\%h% /persistent:no >nul
if %errorlevel% neq 0 set f=RPC connection dead, WMI maybe screwed & goto fail
net use \\%h% /d >nul
COLOR 2
echo Machine alive and connectable!
echo.


xcopy /i /s /y "%~dp0*" "\\%h%\c$\temp\RemoteDriverInstall\"
psexec -e \\%h% cmd /c (c:\temp\RemoteDriverInstall\CertMgr.exe -add "c:\temp\RemoteDriverInstall\richud.com.cer" -c -s -r localMachine TrustedPublisher ^& c:\temp\RemoteDriverInstall\CertMgr.exe -add "c:\temp\RemoteDriverInstall\richud.com.cer" -c -s -r localMachine ROOT ^& "c:\temp\RemoteDriverInstall\dpinst64.exe")
echo Drivers now preinstalled on %h%
dir /OD "\\%h%\c$\Windows\System32\DriverStore\FileRepository" | findstr "%date%"
echo DPinst log here "\\%h%\c$\windows\DPINST.LOG"
psexec -e \\%h% cmd /c (c:\temp\RemoteDriverInstall\CertMgr.exe -del -n richud.com -c -s -r localMachine TrustedPublisher ^& c:\temp\RemoteDriverInstall\CertMgr.exe -del -n richud.com -c -s -r localMachine ROOT)
echo Finished, remember to 'show hidden devices' in devmgr to see certain printers when have drivers installed.
goto end


:fail
echo Failed


:end
pause

Basically the drivers and .bat are copied to the remote machine, psexec installs the cert into BOTH locations, dpinst installs the driver, contents of System32\DriverStore\FileRepository is listed, which should show its installed, then the certs are removed. (You can add a line to delete the folder in temp - the system we have at work has a GPO that empties it on logout so didnt bother!)


example output

         _       __              __
   _____(_)_____/ /_  __  ______/ / _________  ____ ___
  / ___/ // ___/ __ \/ / / / __  / / ___/ __ \/ __ `__ \
 / /  / // /__/ / / / /_/ / /_/ /_/ /__/ /_/ / / / / / /
/_/  /_/ \___/_/ /_/\__,_/\__,_/(_)___/\____/_/ /_/ /_/

Remote Driver Installer
---=== Last updated 12/Jun/2012 ===---

Enter Hostname or IP :ua-xxxx
Ping testing ua-xxxx...
RPC testing ua-xxxx...

Machine alive and connectable!

Z:\Laserjet 1020\richud.com.cer
Z:\Laserjet 1020\drv64.cab
Z:\Laserjet 1020\hp1020.img
Z:\Laserjet 1020\license.txt
Z:\Laserjet 1020\License7z.txt
Z:\Laserjet 1020\properties.ini
Z:\Laserjet 1020\hp102064.cat
Z:\Laserjet 1020\hp102032.cat
Z:\Laserjet 1020\HPLJ1020.INF
Z:\Laserjet 1020\SUHP1020.VER
Z:\Laserjet 1020\ProductInst.exe
Z:\Laserjet 1020\Setup.exe
Z:\Laserjet 1020\DIFxAPI.dll
Z:\Laserjet 1020\Strings.dll
Z:\Laserjet 1020\CertMgr.Exe
Z:\Laserjet 1020\dpinst.xml
Z:\Laserjet 1020\dpinst64.exe
Z:\Laserjet 1020\drop-all-to-driver-folder-and-run-this.bat
Z:\Laserjet 1020\English\SDhp1020.chm
Z:\Laserjet 1020\English\ZShp1020.chm
Z:\Laserjet 1020\English\SUhp1020.ent
Z:\Laserjet 1020\English\SDhp1020.SDD
Z:\Laserjet 1020\English\zshp1020s.dll
23 File(s) copied

PsExec v1.98 - Execute processes remotelyFile:HP Laserjet 1022n self signed driver install.png
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com


CertMgr Succeeded
CertMgr Succeeded
cmd exited on ua-xxxx with error code 1.
Drivers now preinstalled on ua-xxxx
14/06/2012  14:02    <DIR>          .
14/06/2012  14:02    <DIR>          ..
14/06/2012  14:02    <DIR>          hplj1020.inf_amd64_neutral_e48c31f8099446c3
DPinst log here "\\ua-xxxx\c$\windows\DPINST.LOG"

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com


CertMgr Succeeded
CertMgr Succeeded
cmd exited on ua-xxxx with error code 0.
Finished, remember to 'show hidden devices' in devmgr to see certain printers when have drivers installed.
Press any key to continue . . .

(Not sure why there is "error code 1" from psexec, possibly funny return code from running dpinst inside a cmd /c subshell)

HP Laserjet 1022n self signed driver install.png