找回密码
 加入
搜索
查看: 1159|回复: 5

关于一个FOR的批处理至AU3

[复制链接]
发表于 2009-10-30 08:21:39 | 显示全部楼层 |阅读模式
本帖最后由 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)

感谢各位高手指点一下这个的实现方法。
 楼主| 发表于 2009-10-30 08:23:07 | 显示全部楼层
实在不知从何下手了~~~感谢~~~
发表于 2009-10-30 09:57:01 | 显示全部楼层
枚举操作,去源码区看看,有相关的
发表于 2009-10-30 11:59:23 | 显示全部楼层
; 显示当前目录中所有文件的文件名
#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可以照例子添加.!
等待高手们贴出简洁的例子.代码写得很乱.高手别见笑,!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-10-30 12:35:55 | 显示全部楼层
晕死.早上发傻.把思路绕了又绕,
这是修改后的.
#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

评分

参与人数 1金钱 +5 贡献 +1 收起 理由
boyhong + 5 + 1 感谢~

查看全部评分

 楼主| 发表于 2009-10-30 13:00:43 | 显示全部楼层
感谢楼上兄弟,论坛因为有您更精彩~~~
同时受二楼兄弟启发,我正在看:_FileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0]])
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 13:35 , Processed in 0.086872 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表