windows 使用批处理文件注册dll和ocx文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5726678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Register dll and ocx file using batch file
提问by Bimal K.C.
I have dll and ocx file on folder on c dirve and want to register just by clicking on batch file
我在 c 目录上的文件夹中有 dll 和 ocx 文件,只想通过单击批处理文件进行注册
回答by kunal
According to this Microsoft knowledge base article:
Regsvr32.exe usage
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)
When you use
Regsvr32.exe
, it attempts to load the component and call itsDLLSelfRegister
function. If this attempt is successful,Regsvr32.exe
displays a dialog box that indicates success. If the attempt is unsuccessful,Regsvr32.exe
returns an error message. This may include a Win32 error code.
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 错误代码。
Thus, the resulting batch file will be:
因此,生成的批处理文件将是:
echo off
Regsvr32 /s C:\MyDLL.dll
exit
回答by zersina
Try this batch code:
试试这个批处理代码:
for %%f in (*.ocx *.dll) do regsvr32 %%f
Open Notepad and paste in the code, then save the file as register.bat
and run it as an Administrator.
打开记事本并粘贴代码,然后将文件另存为register.bat
并以管理员身份运行。
回答by kfa_tpa
You'll want to run this in silent mode as multiple errors will possibly cause issues with explorer.exe for %x in (c:\windows\system32*.dll) do regsvr32 /s %x
您需要在静默模式下运行它,因为多个错误可能会导致 explorer.exe for %x in (c:\windows\system32*.dll) do regsvr32 /s %x
回答by rerun
Just put regsvr32 pathto.exe
in your batch file, assuming that regsvr32
is on the path.
只需放入regsvr32 pathto.exe
您的批处理文件,假设它regsvr32
在路径上。