你的这行代码run("nero9.bat","",@SW_HIDE)改为
Run(@ComSpec & " /c " & "nero9.bat", @ScriptDir, @SW_HIDE)
试一下。
看你的代码,你好像是要做个有进度条的复制代码!
再给你个下面的代码:; _CopyWithProgress函数将360.exe文件从C盘复制到D盘。
$FileCopy = _CopyWithProgress("C:\360.exe", "D:\360.exe", 2048)
;检查返回代码,看看是否正确复制文件
If $FileCopy = 0 Then
MsgBox(0,"复制完成", "文件复制成功.")
Else
MsgBox(16,"复制完成", "文件复制失败.")
EndIf
Func _CopyWithProgress($inSource, $inDest, $ChunkSize = 2048)
$SourceFile = FileOpen($inSource, 16)
If $SourceFile = -1 Then
MsgBox(16, "Error", "无法打开源文件: " & $inSource)
Exit
EndIf
$DestFile = FileOpen($inDest, 26)
If $SourceFile = -1 Then
MsgBox(16, "Error", "无法打开目标文件: " & $inDest)
Exit
EndIf
$SourceSize = FileGetSize($inSource)
$Chunks = $SourceSize / $ChunkSize
ProgressOn("文件复制", "正在复制...", "从: " & $inSource & @LF & "Dest: " & $inDest)
For $i = 0 to $Chunks
$Data = FileRead($SourceFile, $ChunkSize)
FileWrite($DestFile, $Data)
ProgressSet( (($i + 1) / $Chunks) * 100 )
Next
ProgressOff()
FileClose($SourceFile)
FileClose($DestFile)
$DestSize = FileGetSize($inDest)
If $SourceSize = $DestSize Then
Return 0
Else
Return 1
EndIf
EndFunc
|