pnputil 安装驱动实际运用-遍历当前文件夹下所有.inf文件并安装驱动

来源:互联网 发布:华硕访客网络限速 编辑:程序博客网 时间:2024/06/14 21:45

微软官网介绍 https://technet.microsoft.com/zh-cn/library/ff550419

一、遍历当前文件夹下所有.inf文件并安装驱动

install.cmd

if "%PROCESSOR_ARCHITECTURE%" == "x86" ( set OS_PLATFORM=x86) else (set OS_PLATFORM=x64)::Run script as Admin>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"if %ERRORLEVEL% EQU 0 (if exist "%temp%\getadmin.vbs" del /q "%temp%\getadmin.vbs") else (goto :Fun_UAC_Promptif exist "%temp%\getadmin.vbs" del /q "%temp%\getadmin.vbs"):START@echo.@echo Start install  drivers... cd /d %~dp0%OS_PLATFORM% setlocal enabledelayedexpansionfor /f "delims=" %%b in ('dir /s /b ".\*.inf"') do (set INF_NAME=%%~nbset INF_PATH=%%~dpbecho cd /d !INF_PATH!cd /d !INF_PATH!echo pnputil -i -a !INF_NAME!.infpnputil -i -a !INF_NAME!.inftimeout /t 3)xcopy /y %~dp0%OS_PLATFORM%\43430r0nvram.txt %WINDIR%\System32\Drivers\goto :END:ERRORcolor 4f@echo.@echo ERROR@echo.pause>nulgoto :ERROR:Fun_UAC_Promptif NOT "%~1"=="" set file= ""%~1""(echo Set UAC = CreateObject("Shell.Application"^)@echo UAC.ShellExecute "cmd.exe", "/c %~s0%file%", "", "runas", 1)> "%temp%\getadmin.vbs""%temp%\getadmin.vbs"exit /b 0:END@echo.@echo Successfully installed  drivers@echo.timeout -t 2exit

二、getadmin.vbs自动生成,目的是让脚本以管理员模式运行

Set UAC = CreateObject("Shell.Application")UAC.ShellExecute "cmd.exe", "/c E:\8300_D~1\AP6212\INSTAL~1.CMD", "", "runas", 1



0 0