使用批处理文件注册dll和ocx文件



我在c驱动器上的文件夹上有dll和ocx文件,想通过点击批处理文件

来注册

根据这篇微软知识库文章:

Regsvr32.exe使用

RegSvr32.exe has the following command-line options:
Regsvr32 [/u] [/n] [/i[:cmdline]] dllname
/u - Unregister server
/i - Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall
/n - do not call DllRegisterServer; this option must be used with /i
/s – Silent; display no message boxes (added with Windows XP and Windows Vista)

当您使用Regsvr32.exe时,它尝试加载组件并调用其DLLSelfRegister函数。如果尝试成功,Regsvr32.exe界面弹出成功提示框。如果尝试不成功,Regsvr32.exe返回错误消息。这可能包含一个Win32错误代码。


因此,生成的批处理文件将是:
echo off 
Regsvr32 /s C:MyDLL.dll
exit

试试这个批处理代码:

for %%f in (*.ocx *.dll) do regsvr32 %%f

打开记事本并粘贴代码,然后将文件保存为register.bat并以管理员身份运行。

regsvr32 pathto.exe放到批处理文件中,假设regsvr32在路径上。

您需要在静默模式下运行此程序,因为多个错误可能会导致explorer.exe出现问题For %x in (c:windowssystem32*.dll) do regsvr32/s %x

打开管理命令提示符,在System32和SySWoW64目录中运行以下命令

C:WindowsSystem32> for %1 in (*.dll) do regsvr32 /s %1
C:WindowsSySWow64> for %1 in (*.dll) do regsvr32 /s %1

最新更新