elexy 发表于 2009-3-30 09:58:57

请教一下AU运行bat脚本内容的问题

一个bat文件内容为:For %%a in (*.dll) do regsvr32.exe /s %%a   效果:复制这个BAT到任意目录下,可实现注册当前目录下所有DLL文件。

现在想用AU3编成exe,在 C:\Program Files\物流货运管理系统\Support 这个目录下执行这个命令,我用以下的命令写成AU3里面运行,发现无效,脚本卡着不动了,请教该如何写才能成功

RunWait(@ComSpec & ' For %%a in (*.dll) do regsvr32.exe /s %%a',"", @SW_HIDE)

[ 本帖最后由 elexy 于 2009-3-30 10:02 编辑 ]

netegg 发表于 2009-3-30 15:25:27

为什么用单引号

rolaka 发表于 2009-3-30 15:27:34

:face (32): autoit本身就可以实现...

执行bat的方式不对

漠北雪~狼 发表于 2009-3-31 02:00:00

$search = FileFindFirstFile("*.dll")
If $search = -1 Then Exit
While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        Run(@ComSpec & " /c regsvr32.exe /s " & $file)
WEnd
FileClose($search)

大概就是这样,没有具体去测试...

elexy 发表于 2009-4-1 10:27:10

狼版,实现了但是会弹出无数cmd黑框,是否将这句修改成 Run(@ComSpec & " /c regsvr32.exe /s " & $file,@SW_HIDE)   但是测试了一下,黑框没了,但是执行后不起作用了。。。。

sensel 发表于 2009-4-1 11:18:30

$hSearch = FileFindFirstFile(@ScriptDir & "\*.dll")
If $sSearch = -1 Then Exit 1
While 1
        $sFile = FileFindNextFile($hSearch)
        If @error Then ExitLoop
        RunWait(@SystemDir & '\regsvr32.exe /s "' & @ScriptDir & '\' & $sFile & '"', @ScriptDir, @SW_HIDE)
WEnd
FileClose($hSearch)
Exit

zjimmy 发表于 2009-4-1 11:43:55

原帖由 elexy 于 2009-4-1 10:27 发表 http://www.autoitx.com/images/common/back.gif
狼版,实现了但是会弹出无数cmd黑框,是否将这句修改成 Run(@ComSpec & " /c regsvr32.exe /s " & $file,@SW_HIDE)   但是测试了一下,黑框没了,但是执行后不起作用了。。。。

@SW_HIDE前缺少了执行的目录: @ScriptDir,

elexy 发表于 2009-4-1 22:52:24

回复 6# sensel 的帖子

$hSearch = FileFindFirstFile(@ScriptDir & "\*.dll")
If $sSearch = -1 Then Exit 1
While 1
        $sFile = FileFindNextFile($hSearch)
        If @error Then ExitLoop
        RunWait(@SystemDir & '\regsvr32.exe /s "' & @ScriptDir & '\' & $sFile & '"', @ScriptDir, @SW_HIDE)
WEnd
FileClose($hSearch)
Exit

您写的这段代码用上去以后,弹框提示错误 Line -1Error:变量没有在开始声明

sxd 发表于 2009-4-2 01:17:45

那就声明一下...汗
页: [1]
查看完整版本: 请教一下AU运行bat脚本内容的问题