The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,839 other subscribers

A source for many batch-file tricks: ghidra/launch.bat at master · NationalSecurityAgency/ghidra

Posted by jpluimers on 2026/05/20

If you want to improve your batchfile-fu, this might be your start: [Wayback/Archive] ghidra/launch.bat at master · NationalSecurityAgency/ghidra

After a quick look, I already recognised these tricks:

  • ^<
  • %%#
  • %~
  • set "SUPPORT_DIR=%SUPPORT_DIR:~0,-1%"
  • "%SUPPORT_DIR:!=%"=="%SUPPORT_DIR%"
  • set /A INDEX=!INDEX!+1
  • if %INDEX% geq 6 goto continue1
  • java -version >nul 2>nul
  • for /f "delims=*" %%i in
  • %SystemRoot%\System32\timeout.exe /NOBREAK 1 > NUL
  • exit /B %ERRORLEVEL%
  • ^(

Via:

Swift quoted this source code via [Wayback/Archive] Google Lens OCR:

[Wayback/Archive] Batch file from https://twitter.com/SwiftOnSecurity/status/1644002540810280964 (hope there are no typos)

–jeroen



:: WMI repair has not yet been attempted, starting attempt.
:: Creating tag to prevent reoccurance.
:: Logging event.
:: Stopping Windows Update.
"C:\Windows\system32\net.exe" stop wuauserv
rd "C:\Windows\Software Distribution" /5 /Q
:: Enabling cloud repair by temporarily overriding update settings.
"C:\Windows\system32\reg.exe" add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing" /v RepairContentServerSource /t REG_DWORD /d 2 /f
"C:\Windows\system32\reg.exe" add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Update" /v DoNotConnectToWindows Update InternetLocations /t REG_DWORD /d 0 /f
"C:\Windows\system32\reg.exe" add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Update\AU" /v AllowMUUpdateService /t REG_DWORD /d 1 /f
"C:\Windows\system32\reg.exe" add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Update\AU" /v IncludeRecommended Updates /t REG_DWORD /d 1 /f
"C:\Windows\system32\reg.exe" add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Update\AU" /v UseWUServer /t REG_DWORD d @ /f
:: Starting Windows Update service again. "C:\Windows\system32\net.exe"
start wuauserv
:: Before proceeding, attempt to repair component store.
"C:\Windows\system32\DISM.exe" /Online /Cleanup-Image /RestoreHealth
:: Before proceeding, attempt to repair system files.
start "" /wait /b "C:\Windows\system32\sfc.exe" /scannow
:: Repair supporting DLLS http://www.slyar.com/blog/solve-bitlokcer-invalid-namespace-error.html
"C:\Windows\system32\regsvr32.exe" /s "C:\Windows\system32\scecli.dll"
"C:\Windows\system32\regsvr32.exe" /s "C:\Windows\system32\userenv.dll"
:: Stop WMI service.
"C:\Windows\system32\net.exe" stop winmgmt /y
"C:\Windows\system32\taskkill.exe" /im "wmipryse.exe" /f
:: Register all WBEM DLLs.
for /f %%s in ('dir /b C:\Windows\system32\wbem\*.dll') do (
"C:\Windows\system32\regsvr32.exe" /s "C:\Windows\system32\wbem\%%s"
)
for /f %%s in ('dir /b C:\Windows\sysWOW64\wbem\*.dll") do (
"C:\Windows\sysWOW64\regsvr32.exe" /s "C:\Windows\sysWOW64\wbem\%%s"
)
:: Restore WMI service.
"C:\Windows\system32\sc.exe" config winmgmt start= Auto
"C:\Windows\system32\net.exe" start winmgmt
:: Resync performance counters.
"C:\Windows\System32\wbem\winmgmt.exe" /resyncperf
:: Register WMI EXES.
:: Attribution– ConfigMgrClientHealth.ps1.
for %%1 IN (unsecapp.exe, wmiadap.exe, wmiapsrv.exe, wmipryse.exe, scrcons.exe) do (
if exist "C:\Windows\system32\wbem\%%1" (
"C:\Windows\system32\wbem\%%1" /RegServer
)
if exist "C:\Windows\sysWOW64\wbem\%%i" (
"C:\Windows\sysWOW64\wbem\%1" /RegServer
)
)
:: Registering MOFs
for /f%%s in ('dir /b C:\Windows\system32\wbem\*.mof C:\Windows\system32\wbem\*.mfl') DO mofcomp "C:\Windows\system32\wbem\%%s"

view raw

wmi-repair.bat

hosted with ❤ by GitHub

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.