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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:19:03  来源:igfitidea点击:

Register dll and ocx file using batch file

windowswindows-xp

提问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:

根据这篇 Microsoft 知识库文章

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 its DLLSelfRegisterfunction. If this attempt is successful, Regsvr32.exedisplays a dialog box that indicates success. If the attempt is unsuccessful, Regsvr32.exereturns 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.batand 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.exein your batch file, assuming that regsvr32is on the path.

只需放入regsvr32 pathto.exe您的批处理文件,假设它regsvr32在路径上。