DenQ 发表于 2010-8-8 22:15:37

超出数组错误.

本帖最后由 DenQ 于 2010-8-8 22:17 编辑

这段代码有什么问题吗?

Func _ReStart() ;利用Devcon工具读取DEV.ID以及重新启动网络连接
If FileExists (@ScriptDir & "\devcon.exe") = 1 Then   
RunWait (@ComSpec & ' /c devcon find pci\* > "'&@TempDir&'"\Dev.txt',"",@SW_HIDE)
$i = 0
$file = FileOpen(@TempDir&"\Dev.txt", 0)
    While 1
    $i = $i + 1
    $lineWherther = FileReadLine($file)
    $Wherther = StringSplit($lineWherther,":")
    If StringInStr ($Wherther, $Temp3) Then ExitLoop
    Wend
$line = FileReadLine($file,$i)
$Split = StringSplit($Line,"&")
FileClose($file)

RunWait ( "devcon disable *"&$Split&"*","",@SW_HIDE)
RunWait ("devcon enable *"&$Split&"*","",@SW_HIDE)
Else
    MsgBox(0, "错误", "缺少devcon.exe文件!"&@CRLF&"请重新启动主程序!",5)
    _Exit()
EndIf
EndFunc

放入开机运行出错, 报错 :错误的数组或数组超出

然后程序退出后,, 再次运行就不报错了..   不知道哪里出了问题.

xsjtxy 发表于 2010-8-8 22:27:52

应该是速度太快了。devcon可能是依赖某个服务工作的。你等待服务启动了再运行你的脚本应该就行了。
加个sleep
5秒或者10秒。

DenQ 发表于 2010-8-8 22:28:32

本帖最后由 DenQ 于 2010-8-8 22:40 编辑

回复 2# xsjtxy


      谢谢了。 我 先测试一下...


      还是不行 我 Sleep 20秒都还是出错.

netegg 发表于 2010-8-8 23:21:11

先检查$Line的返回值是什么再说
页: [1]
查看完整版本: 超出数组错误.