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

时间:2011-04-20 07:06:22

标签: windows windows-xp

我在c盘上的文件夹上有dll和ocx文件,只想通过点击批处理文件进行注册

4 个答案:

答案 0 :(得分:6)

根据this Microsoft knowledge base article

  

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

答案 1 :(得分:3)

试试这个批处理代码:

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

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

答案 2 :(得分:1)

只需将regsvr32 pathto.exe放入批处理文件中,假设路径上有regsvr32

答案 3 :(得分:1)

您希望以静默方式运行此操作,因为多个错误可能会导致explorer.exe出现问题 for%x in(c:\ windows \ system32 * .dll)do regsvr32 / s%x