Apr 6, 2020 09:57 PM
(This post was last modified: Apr 6, 2020 09:58 PM by SIM-4581439.)
This isn't complex by any means, but I had some .ocx models that I needed to register and I didn't want to manually do them through the terminal. So lo and behold...
Note: the UAC invoke is not mine. This script indexes all libraries and models in the current directory was well as the sub-directories too.
Note: the UAC invoke is not mine. This script indexes all libraries and models in the current directory was well as the sub-directories too.
Code
@echo off >NUL
REM UAC Elevation script from: shorturl.at/pyV35
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo [REQUESTING ELEVATION]
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
Set "index=%temp%\lib_list.ini"
dir /b /s *.ocx >"%index%"
dir /b /s *.dll >>"%index%"
Setlocal EnableDelayedExpansion
For /F "delims=" %%A IN (%index%) DO (
set "path=%%A"
regsvr32 "!path!"
)
DEL /F /Q "%index%"
cls
ECHO ALL LIBRARIE(S) / MODEL(S) REGISTERED
Timeout /T 5 >NUL
EXIT

