Last active
December 23, 2017 18:23
-
-
Save dayt0n/a841f0e848cc039d38f0445d326568aa to your computer and use it in GitHub Desktop.
install drivers onto windows 7 install USB/DVD for motherboards made after the release of windows 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set argC=0 | |
for %%x in (%*) do Set /A argC+=1 | |
if not %argC% == 2 ( | |
echo Incorrect usage | |
echo usage: installDrivers.bat [USB location- F:, E:, etc] [exact driver directory] | |
goto endingtime | |
) | |
set USB=%1 | |
set driverDir=%2 | |
cd %APPDATA% | |
if exist installDrivers ( | |
rmdir /s /q installDrivers | |
) | |
mkdir installDrivers | |
cd installDrivers | |
echo [installDrivers] Copying Drivers... | |
xcopy %driverDir% toInstall /O /X /E /H /K /I | |
echo [installDrivers] Copying boot.wim | |
echo f|xcopy %USB%\sources\boot.wim boot.wim /O /X /E /H /K | |
echo Copying install.wim (this may take a while) | |
echo f|xcopy %USB%\sources\install.wim install.wim /O /X /E /H /K | |
mkdir mount | |
echo [installDrivers] Installing drivers to boot.wim index 1... | |
dism /mount-wim /wimfile:boot.wim /index:1 /mountdir:mount | |
dism /image:mount /add-driver:"toInstall" /recurse | |
dism /unmount-wim /mountdir:mount /commit | |
echo [installDrivers] Installing drivers to boot.wim index 2... | |
dism /mount-wim /wimfile:boot.wim /index:2 /mountdir:mount | |
dism /image:mount /add-driver:"toInstall" /recurse | |
dism /unmount-wim /mountdir:mount /commit | |
dism /Get-WimInfo /WimFile:install.wim > installInfo.txt | |
find /c "Index" < installInfo.txt > cleanInfo.txt | |
set /p count=<cleanInfo.txt | |
del cleanInfo.txt | |
del installInfo.txt | |
REM Stuff with the indexes for install.wim. Gets to be a lot when you have a 4 in 1 install ISO | |
set /p ifAll="[installDrivers] There are %count% indexes on install.wim. Would you like to install on all of them? [Y/N]: " | |
if %ifAll% == Y ( | |
FOR /L %%A in (1,1,%count%) DO ( | |
echo [installDrivers] Mounting install.wim index %%A | |
dism /mount-wim /wimfile:install.wim /index:%%A /mountdir:mount | |
echo [installDrivers] Installing drivers to index %%A | |
dism /image:mount /add-driver:"toInstall" /recurse | |
echo [installDrivers] Unmounting install.wim index %%A | |
dism /unmount-wim /mountdir:mount /commit | |
) | |
) else ( | |
dism /Get-WimInfo /WimFile:install.wim | |
set /p myIndex="[installDrivers] Which index would you like to use? [1-%count%]: " | |
echo %myIndex% | |
echo [installDrivers] Mounting install.wim index %myIndex% | |
dism /mount-wim /wimfile:install.wim /index:%myIndex% /mountdir:mount | |
echo [installDrivers] Installing drivers to index %myIndex% | |
dism /image:mount /add-driver:"toInstall" /recurse | |
echo [installDrivers] Unmounting install.wim index %myIndex% | |
dism /unmount-wim /mountdir:mount /commit | |
) | |
echo [installDrivers] Moving install.wim back to device %USB% | |
echo f|xcopy %APPDATA%\installDrivers\install.wim %USB%\sources\install.wim /O /X /E /H /K /Y | |
echo [installDrivers] Moving boot.wim back to device %USB% | |
echo f|xcopy %APPDATA%\installDrivers\boot.wim %USB%\sources\boot.wim /O /X /E /H /K /Y | |
cd .. | |
echo [installDrivers] Cleaning up... | |
rmdir /s /q installDrivers | |
echo [installDrivers] Done | |
:endingtime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment