【发布时间】:2014-07-09 04:11:05
【问题描述】:
我想创建一个自动运行的数据备份。为此,我想在 system32 中注册所有 ocx 和 dll。我想为此使用循环,因为当我们添加新 dll 时很容易,我们不需要在批处理文件中为此编写额外的代码。以下代码工作正常,但我想使用循环。
Set "tempFile=msdbrptr.dll"
Set "tempPath=%rootPath%%tempFile%
if not exist %tempPath% @ copy controls\%tempFile% %tempPath%
regsvr32 %tempPath%
Set "tempFile=scrrun.dll"
Set "tempPath=%rootPath%%tempFile%
if not exist %tempPath% @ copy controls\%tempFile% %tempPath%
regsvr32 %tempPath%
我们如何使用 for 循环来做到这一点..
【问题讨论】:
-
for %%A in (%windir%\system32\*.ocx %windir%\system32\*.dll) do (regsvr32 %%A&regsvr32 /i %%A) -
在上面的代码中,我从控制文件夹复制并在 system32 中注册.. for %%A in (%windir%\system32*.ocx %windir%\system32*.dll) do (regsvr32 %%A®svr32 /i %%A) 我们在这段代码中定义控制文件夹的地方
-
没有控制目录之类的东西。控制面板是一个虚拟文件夹,里面没有文件。您还编辑了我的代码,因此通过删除反斜杠将不再起作用。
-
我是说您正在从 windir 中选择 dll 和 ocx 并在 sys32 中注册...我想从外部文件夹复制 dll 和 ocx 并注册到 sys32 或 syswow32 中,如果不存在 %tempPath% @ copy controls\%tempFile% %tempPath% regsvr32 %tempPath% where rootpath is rootpath= %SystemRoot%\System32\"
-
忘记变量,用简单的英语交谈。我不知道你认为你的变量是什么(至少有一些是不必要的定义。你建议如何告诉复制到哪个文件夹?
标签: loops batch-file