关于一个FOR的批处理至AU3
本帖最后由 boyhong 于 2009-10-30 13:00 编辑for %%l in (%windir%\system32\*.ocx) do regsvr32.exe /s %%l
for %%l in (%windir%\system32\*.dll) do regsvr32.exe /s %%l
将上边的批处理转为AU3,并回显出每个注册的DLL:SplashTextOn ("务必稍等...", @LF&"正进行 jscript.dll 的注册修复..请稍等......",550,65)
感谢各位高手指点一下这个的实现方法。 实在不知从何下手了~~~感谢~~~ 枚举操作,去源码区看看,有相关的 ; 显示当前目录中所有文件的文件名
#include<array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$search = FileFindFirstFile("c:\windows\system32\*.ocx")
; 检查搜索是否成功
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
Dim $n, $i, $s
$i = 0
$n = 0
$s = 0
While 1
$file = FileFindNextFile($search)
$n = $n + 1
If @error Then
FileClose($search)
ExitLoop
EndIf
WEnd
Dim $filelist[$n]
$search = FileFindFirstFile("c:\windows\system32\*.ocx")
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
While 1
$file = FileFindNextFile($search)
$filelist[$i] = $file
$i = $i + 1
If @error Then ExitLoop
WEnd
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 523, 360, 188, 111)
$Label1 = GUICtrlCreateLabel("Label1", 48, 48, 340, 17)
$Button1 = GUICtrlCreateButton("Button1", 96, 128, 73, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileClose($search)
Exit
Case $Button1
For $s = 0 To $n - 1
If $filelist[$s] = '' Then
GUICtrlSetData($Label1, '所有组件注册完毕!')
Else
GUICtrlSetData($Label1, '正在注册:' & $filelist[$s] & '组件')
ShellExecuteWait('regsvr32.exe', '/s' & $filelist[$s], '', 'open')
Sleep(200)
EndIf
Next
FileClose($search)
EndSwitch
WEnd用最笨的办法给你写了一个例子,!! 只写了OCX,DLL可以照例子添加.!
等待高手们贴出简洁的例子.代码写得很乱.高手别见笑,! 晕死.早上发傻.把思路绕了又绕,
这是修改后的.#include<array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$search = FileFindFirstFile("c:\windows\system32\*.ocx")
; 检查搜索是否成功
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 523, 360, 188, 111)
$Label1 = GUICtrlCreateLabel("Label1", 48, 48, 340, 17)
$Button1 = GUICtrlCreateButton("Button1", 96, 128, 73, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileClose($search)
Exit
Case $Button1
While 1
$file = FileFindNextFile($search)
GUICtrlSetData($Label1, '正在注册:' & $file & '组件')
ShellExecuteWait('regsvr32.exe', '/s' & $file, '', 'open')
Sleep(200)
If $file='' or @error Then
GUICtrlSetData($Label1, '所有组件注册完毕!')
ExitLoop
EndIf
WEnd
FileClose($search)
EndSwitch
WEnd 感谢楼上兄弟,论坛因为有您更精彩~~~
同时受二楼兄弟启发,我正在看:_FileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0]])
页:
[1]