|
本帖最后由 szhzps 于 2012-2-19 16:32 编辑
我写了一段脚本,下载暴风到指定的文件夹内,如果带路径就不成功,下载到当前位置就正常,请大侠指教?
Dim $rar, $path,$rul,$tr,$setup
$url = "http://dl.baofeng.com/baofeng5/Baofeng5-5.09.0215.exe"
$exe = "Baofeng5-5.09.exe"
$path = "d:\softfiles\"
;检测文件夹是否存在
If FileExists($path) Then
DirCreate ($path)
endif
;取文件名
$INETGET2 = StringStripWS ($url,4)
;MsgBox(0,"完成提示框","检测到的文件名:" & $INETGET2)
IF $exe = " " or $exe = "" then ;如果"本地文件路径"为空格或为空,那么从远程路径里面取文件名
$setup = ""
$InetgetCUT = $Inetget2
while 1 ;;;这个循环就是从远程路径里面取文件名了,从最后一个字符一直向前循环,遇到"/"字符时跳出循环
$str = StringRight ($InetgetCUT,1)
;MsgBox(0,"完成提示框","检测到的文件名:" & $str)
Select
Case $str = ""
RETURN
Case $str = "/"
EXITLOOP
Case Else
$InetgetCUT = StringTrimRight ($InetgetCUT,1)
$setup = $str & $setup
;MsgBox(0,"完成提示框","检测到的文件名:" & $setup)
EndSelect
wend
;ELSE
$exe = $SETUP ;;否则把"本地文件路径"中的内容放入$SETUP
ENDIF
;开始下载
;MsgBox(0,"完成提示框","开始下载,请稍假")
$pathexe = $path & $exe
$load = InetGet ($url,$pathexe,1,1)
MsgBox(0,"完成提示框","文件名:" & $pathexe)
ProgressOn("炫狐软件在线安装器", "正在为你下载,请稍后.....")
While 1
If InetGetInfo($load, 2) = True Then ExitLoop
InetGetInfo($load, 1)
$rou = Round(InetGetInfo($load, 0) / InetGetInfo($load, 1), 2) * 100
ProgressSet($rou, "已下载:" & $rou & "%" & " "&"保存路径:" & $path)
Sleep(100)
WEnd
ProgressSet(100, "下载完成")
ProgressOff()
Run($pathexe) |
|