Driverstore Cleaner script (or anything else...)

fxart

New Member
Hi Nuhi, I love your tool very much. I'am a registered user. Only one flavour: can you add something to reduce the size of Windows after setup?
My images contains a lot of drivers for differents devices. I want to support many brands like ASRock, Advantech, Intel and MSI.
I have injected all the drivers we need to build a proper OS image that install everithing automatically on different HW configurations. These images are customized with many apps and tools we needs.
After setup, the drivestore appear to bigger so I want reduce this delething all the unused drivers. Can you help me with a script or something else to be launched after the first logon and only one time? is also possible to delete automatically logs and anything else not needed like setup logs? My dream is to obtain a fully working OS installation with only the propers things and not with space to be cleared with external tools.
Can you also integrate the possibility to HIDDEN some Windows settings like FEEDBACKS in privacy and not only disable them?
The must is to permits some features like Winreducer, to add background pics, customize boot.wim, etc.
For now, a script to clear the Drivestore is the most urgent feature. If anyone can help, tell me something. I can pay for this job.
After first clean, this script must be disabled or deleted. i don't know how make this and how to luanch from $OEM$ folder/scripts.
Thanks in advance
PLEASE PLEASE PLEASE!
 

nuhi

NTLite developer
Staff member
fxart, thanks.

Interesting about the driver cleanup, seems obvious, adding to the wishlist. In the meantime try the Clanger link.

Btw to delete logs there is "Cache and temp files" component, re-remove that live from time to time.

Not sure about the feedback privacy question, you can remove telemetry, error reporting and Windows Insider Hub components already.

Adding background, pics...yeah would be nice, but then the tool is getting out of its tracks, not easy to maintain all at once. Don't want to be jack of all trades, master of none :)
 

fxart

New Member

Hi, this is the first link that I have tried. It works but I cannot start it automatically. I have put in my $OEM$ foldder and the script start but the powershell interface does not accept the commands at first logon like -NoExecution Policy Bypass etc.
I know I'am a stress man but if anyone help me HOW TO FORCE his launch when system has finished his setup (first logon). After, PC must be rebooted and the setup procedure finished removing the setupcomplete.cmd from registry.

PS: for the backgrounds, i have asked for a tool that permits to add the backgrounds and some others features in the boot.wim, easily...

For Nuhi, if you are able to inject the script of above into your tool, please add also something that polish the system automatically without activate WINSXS cleanup that can take too long time.

Thanks a lot.

Please help.
 

George King

Active Member
Here is DriverStore cleanup that I wrote some time ago :)

CleanDriverStore.cmd
Code:
@echo off
title Windows DriverStore CleanUp
cls

echo.
echo Creating Restore Point

"%WinDir%\System32\wbem\wmic.exe" /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "DriverStore CleanUp %DATE%", 100, 1 >nul

REM Get count of all OEM drivers
set OEMDRVCNT=0
for %%A in ("%WinDir%\inf\OEM*.inf") do set /a OEMDRVCNT+=1

echo.

if exist "%WinDir%\Logs\CleanDriverStore.log" del /q /s "%WinDir%\Logs\CleanDriverStore.log"

REM Remove unused 3rd drivers, drivers in use will be skipped with error
for /L %%A in (0,1,%OEMDRVCNT%) do (
    if exist "%WinDir%\inf\OEM%%A.inf" (
        if "%~1" == "/log" (
            echo Deleting "%WinDir%\inf\OEM%%A.inf" >> "%WinDir%\Logs\CleanDriverStore.log"
            "%WinDir%\system32\pnputil.exe" -d "OEM%%A.inf" >> "%WinDir%\Logs\CleanDriverStore.log"
        ) else (
            echo Deleting "%WinDir%\inf\OEM%%A.inf"
            "%WinDir%\system32\pnputil.exe" -d "OEM%%A.inf"
        )
    )
)

exit

If you want to get log file run CleanDriverStore.cmd with /log switch.
Then you can find log file in "%WinDir%\Logs\CleanDriverStore.log"
 
Last edited:

Clanger

Well-Known Member
George King to remove"create a restore point" just remove the following?
Code:
echo Creating Restore Point

"%WinDir%\System32\wbem\wmic.exe" /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "DriverStore CleanUp %DATE%", 100, 1 >nul
 

George King

Active Member
Yes, but its recomended for testing on real machine.. Some drivers can broke your system - specially I saw that on AMD sata drivers
 

fxart

New Member
Here is DriverStore cleanup that I wrote some time ago :)

CleanDriverStore.cmd
Code:
@echo off
title Windows DriverStore CleanUp
cls

echo.
echo Creating Restore Point

"%WinDir%\System32\wbem\wmic.exe" /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "DriverStore CleanUp %DATE%", 100, 1 >nul

REM Get count of all OEM drivers
set OEMDRVCNT=0
for %%A in ("%WinDir%\inf\OEM*.inf") do set /a OEMDRVCNT+=1

echo.

REM Remove unused 3rd drivers, drivers in use will be skipped with error
for /L %%A in (0,1,%OEMDRVCNT%) do (
    if exist "%WinDir%\inf\OEM%%A.inf" (
        echo Deleting "%WinDir%\inf\OEM%%A.inf"
        "%WinDir%\system32\pnputil.exe" -d "OEM%%A.inf"
    )
)

exit

Thanks.

Today I’ll try it on some LTSB and LTSC configs.
Please, can you also attach the correct “setupcomplete.cmd” string that launch your script and the additional parameters to disable it after the first logon procedure?

with the original script, the sistem restart in less of a second without cleaning nothing.
On virtual machine works well when on real configs not. Powershell script does not launch.
Same config and same image.
If I set the NTLITE option to create shortcuts for the drivers to save space, this script works well ??
This script must work on 10 pro 1909, LTSB and LTSC without making a restore point.
all the images of above are fully updated.
No precious components are removed. Only disabled some tweaks for gain performances like “disabling remote compression”.

Nuhi: can you add some tricks in the unattended section to force the power schemes to DISABLE the adaptive brightness and the disk disable for all the users?
Hiding privacy setting must set the BASIC level and HIDE from the privacy menu the Privacy and Feedback string,

Thanks in advance.


sorry for my bad english.
 

George King

Active Member
fxart, post your SetupComplete.cmd... So we can see whats going wrong. I'm not using this method. I'm using OOBE.cmd and RunOnceEx for launching scripts and installers.
 

fxart

New Member
fxart, post your SetupComplete.cmd... So we can see whats going wrong. I'm not using this method. I'm using OOBE.cmd and RunOnceEx for launching scripts and installers.

Hi Mr:

Setupcomplete:
@echo off
for %%w IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%w:\sources\install.esd SET CDROM=%%w:
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx /f
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
REM REG ADD %KEY% /v Flags /t REG_DWORD /d "20" /f
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v Setup /t REG_SZ /d "cmd.exe /C start /min C:\Windows\Setup\Scripts\Cleanup.cmd" /f
Exit

previous "cleanup script"
@echo off
for /L %%A in (1,1,300) do (
echo Deleting OEM%%A.INF
pnputil /d OEM%%A.INF
)

net accounts /maxpwage:unlimited
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v Setup /f
shutdown -r -f -t 3
exit


however, if i launch your script now inside Windows with admin rights, nothing happen .... why?
User account control isa already disabled and all the users are admin only!

sigh!
 

George King

Active Member
fxart, This seem like you absolutly don't know what are you doing in CMD script...

If you would like to start script called cleanup only once use RunOnce instead

Your script should look like this

Code:
@echo off

REM Add Cleanup script, that will run only one time
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v "Cleanup" /t REG_SZ /d "cmd.exe /C start /min %WinDir%\Setup\Scripts\Cleanup.cmd" /f >nul

REM Password never expire
net accounts /maxpwage:unlimited >nul

REM Creating Restore Point
"%WinDir%\System32\wbem\wmic.exe" /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "DriverStore CleanUp %DATE%", 100, 1 >nul


REM Get count of all OEM drivers
set OEMDRVCNT=0
for %%A in ("%WinDir%\inf\OEM*.inf") do set /a OEMDRVCNT+=1

echo.

REM Remove unused 3rd drivers, drivers in use will be skipped with error
for /L %%A in (0,1,%OEMDRVCNT%) do (
    if exist "%WinDir%\inf\OEM%%A.inf" (
        echo Deleting "%WinDir%\inf\OEM%%A.inf"
        "%WinDir%\system32\pnputil.exe" -d "OEM%%A.inf"
    )
)


REM Reboot
shutdown -r -f -t 3

exit

Btw, you need to learn about how these things work before you start to use them
 

fxart

New Member
fxart, This seem like you absolutly don't know what are you doing in CMD script...

If you would like to start script called cleanup only once use RunOnce instead

Your script should look like this

Code:
@echo off

REM Add Cleanup script, that will run only one time
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v "Cleanup" /t REG_SZ /d "cmd.exe /C start /min %WinDir%\Setup\Scripts\Cleanup.cmd" /f >nul

REM Password never expire
net accounts /maxpwage:unlimited >nul

REM Creating Restore Point
"%WinDir%\System32\wbem\wmic.exe" /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "DriverStore CleanUp %DATE%", 100, 1 >nul


REM Get count of all OEM drivers
set OEMDRVCNT=0
for %%A in ("%WinDir%\inf\OEM*.inf") do set /a OEMDRVCNT+=1

echo.

REM Remove unused 3rd drivers, drivers in use will be skipped with error
for /L %%A in (0,1,%OEMDRVCNT%) do (
    if exist "%WinDir%\inf\OEM%%A.inf" (
        echo Deleting "%WinDir%\inf\OEM%%A.inf"
        "%WinDir%\system32\pnputil.exe" -d "OEM%%A.inf"
    )
)


REM Reboot
shutdown -r -f -t 3

exit

Btw, you need to learn about how these things work before you start to use them

Hi George, thank you very much.
I know I’am not a genie.
Sorry for that. I never find something that is too clear.
Only many examples and nothing more.
I have mixed many of them.

Thanks a lot.
 

Clanger

Well-Known Member
ahh, ok then, ping me when its done and i'll change it. doesnt hurt to list it in the meantime :)
 
Top