From ada133f96ac38e20c5e35c3eeeca7be10a891480 Mon Sep 17 00:00:00 2001 From: JG <it@hgw-tornesch.de> Date: Thu, 4 Aug 2022 15:18:08 +0200 Subject: [PATCH] Added fix for 0x00000bcb & auto admin detection... to all scripts needing it --- Fix edgegdi.dll.bat | 29 +++++++++++++ Fix long login times.bat | 43 ++++++++++++++++--- Fix printer installation error 0x00000bcb.bat | 41 ++++++++++++++++++ Fix printer not install- and selectable.bat | 29 +++++++++++++ Fix work file not createable.bat | 29 +++++++++++++ README.md | 3 +- Remove Java remains.bat | 29 +++++++++++++ 7 files changed, 195 insertions(+), 8 deletions(-) create mode 100644 Fix printer installation error 0x00000bcb.bat diff --git a/Fix edgegdi.dll.bat b/Fix edgegdi.dll.bat index 302ba91..bdb7249 100644 --- a/Fix edgegdi.dll.bat +++ b/Fix edgegdi.dll.bat @@ -1,4 +1,33 @@ @echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part robocopy "C:\Windows\SysWOW64" "%localappdata%\Temp" EdgeManager.dll ren "%localappdata%\Temp\EdgeManager.dll" "edgegdi.dll" robocopy "%localappdata%\Temp" "C:\Windows\SysWOW64" "edgegdi.dll" diff --git a/Fix long login times.bat b/Fix long login times.bat index fe104b7..425647e 100644 --- a/Fix long login times.bat +++ b/Fix long login times.bat @@ -1,13 +1,42 @@ @echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part pushd "C:\Users" && ( for /f "tokens=*" %%a in ('dir /A:D /b') do ( - if not "%%a" == "Public" if not "%%a" == "All Users" if not "%%a" == "Default User" ( - pushd "C:\Users\%%a\AppData\Local\Microsoft\Windows" && ( - rd /s /q WebCache - del /q /f WebCacheLock.dat - ) - popd - ) + if not "%%a" == "Public" if not "%%a" == "All Users" if not "%%a" == "Default User" ( + pushd "C:\Users\%%a\AppData\Local\Microsoft\Windows" && ( + rd /s /q WebCache + del /q /f WebCacheLock.dat + ) + popd + ) ) popd ) diff --git a/Fix printer installation error 0x00000bcb.bat b/Fix printer installation error 0x00000bcb.bat new file mode 100644 index 0000000..f8c2d94 --- /dev/null +++ b/Fix printer installation error 0x00000bcb.bat @@ -0,0 +1,41 @@ +@echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part +echo Adding temporary registry hack. . . +reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint" /v "RestrictDriverInstallationToAdministrators" /t REG_DWORD /d 0 /f +echo. +echo Add your printer the usual way now. +pause +echo. +echo TRemoving registry hack again. . . +reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint" /v "RestrictDriverInstallationToAdministrators" /f +echo Done. +pause +exit diff --git a/Fix printer not install- and selectable.bat b/Fix printer not install- and selectable.bat index 17659ba..4a1bee4 100644 --- a/Fix printer not install- and selectable.bat +++ b/Fix printer not install- and selectable.bat @@ -1,4 +1,33 @@ @echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part net stop spooler pushd "%~dp0\ScriptFiles\PrinterNotInstallable" && ( reg import "Printer Spooler Registry.reg" diff --git a/Fix work file not createable.bat b/Fix work file not createable.bat index 3048432..09f466b 100644 --- a/Fix work file not createable.bat +++ b/Fix work file not createable.bat @@ -1,4 +1,33 @@ @echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part echo Create backups of registry entries to delete in Downloads folder. . . reg export "HKCR\CLSID\{84F66100-FF7C-4fb4-B0C0-02CD7FB668FE}" "%userprofile%\Downloads\SBLOG_RegBackup_WordPreview.reg" reg export "HKCR\CLSID\{65235197-874B-4A07-BDC5-E65EA825B718}" "%userprofile%\documents\SBLOG_RegBackup_PowerPointreview.reg" diff --git a/README.md b/README.md index 1aee39a..e739597 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Windows error fixing scripts A collection of scripts to fix various errors cropping up in Windows.\ -These are made for double-click execution via file explorer. +These are made for running via double-clicking the scripts in file explorer. * `Fix Outlook Temp folder.bat` empties the Temp folder of MS Office Outlook to fix it filling up the main harddrive. * `Fix blank icons` fixes desktop icons appearing as blank white rectangles instead of their usual icon. Adapted from the [ElevenForums](https://www.elevenforum.com/t/rebuild-icon-cache-in-windows-11.2049/) ([Archived Version](https://web.archive.org/web/20211017173532/https://www.elevenforum.com/t/rebuild-icon-cache-in-windows-11.2049/)) * `Fix edgegdi.dll.bat` fixes the `edgegdi.dll` not being available for certain tasks, leading to errors thrown. * `Fix long login times.bat` deletes `WebCache`and `WebCacheLock.dat` on all normal users to fix unbearable login times after installing windows through a custom made image. +* `Fix printer installation error 0x00000bcb.bat` adds a temporary registry hack to fix error 0x00000bcb during printer install, then removes it again afterwards. * `Fix printer not install- and selectable.bat` fixes a problem where no printer can be selected or even installed, caused by corrupted files. * `Fix prompt for password change.bat` disables the prompting for a password change when using a Microsoft account. * `Fix search & settings.bat` fixes the windows search and the settings app not starting up correctly and freezing. diff --git a/Remove Java remains.bat b/Remove Java remains.bat index 6850d10..faae327 100644 --- a/Remove Java remains.bat +++ b/Remove Java remains.bat @@ -1,4 +1,33 @@ @echo off +REM Ensure Admin rights +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>nul 2>nul +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) + +echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +echo args = "ELEV " >> "%vbsGetPrivileges%" +echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +echo Next >> "%vbsGetPrivileges%" +echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit /B + +:gotPrivileges +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + + +REM Functional part del "C:\Program Files (x86)\Common Files\Java\*" /s /q /f reg query hklm\software\classes\installer\products /f "java(tm) 7" /s | find "HKEY_LOCAL_MACHINE" > deljava.txt for /f "tokens=* delims= " %%a in (deljava.txt) do reg delete %%a /f -- GitLab