[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] 批处理start命令无法运行

不知道是哪里写错了,目录下是存在file.exe photo.exe 和psd.exe的而且这三个是安装包里面都包含了1-9 a-k的所有程序为了跳过管理员所以静默解压到%temp%目录下,但就是运行不了一直下载,有大神知道哪里出错了吗,语法什么的都没错啊
  1. @echo off&Setlocal enabledelayedexpansion&mode con cols=90 lines=30
  2. set command=%windir%\command
  3. if not exist %command% md %command%
  4. cd /d %command%||call:usa
  5. :::::::::::::::::::::::::::::::::::EXE:::::::::::::::::::::::::::::::::::
  6. if not exist 1.exe (start /wait file.exe||Set url=a&call:down)
  7. if not exist 2.exe (start /wait file.exe||Set url=a&call:down)
  8. if not exist 3.exe (start /wait file.exe||Set url=a&call:down)
  9. if not exist 4.exe (start /wait file.exe||Set url=a&call:down)
  10. if not exist 5.exe (start /wait file.exe||Set url=a&call:down)
  11. if not exist 6.exe (start /wait file.exe||Set url=a&call:down)
  12. if not exist 7.exe (start /wait file.exe||Set url=a&call:down)
  13. if not exist 8.exe (start /wait file.exe||Set url=a&call:down)
  14. :::::::::::::::::::::::::::::::::::BMP:::::::::::::::::::::::::::::::::::
  15. if not exist a.bmp (start /wait photo.exe||Set url=b&call:down)
  16. if not exist b.bmp (start /wait photo.exe||Set url=b&call:down)
  17. if not exist c.bmp (start /wait photo.exe||Set url=b&call:down)
  18. if not exist d.bmp (start /wait photo.exe||Set url=b&call:down)
  19. if not exist e.ico (start /wait photo.exe||Set url=b&call:down)
  20. :::::::::::::::::::::::::::::::::::PSD:::::::::::::::::::::::::::::::::::
  21. if not exist f.psd (start /wait psd.exe||Set url=c&call:down)
  22. if not exist i.psd (start /wait psd.exe||Set url=c&call:down)
  23. if not exist j.psd (start /wait psd.exe||Set url=c&call:down)
  24. if not exist k.psd (start /wait psd.exe||Set url=c&call:down)
  25. echo ok&pause
  26. 。。。。。
  27. :Test
  28. set "g=0.0.0.0" & set "j="
  29. for /f "tokens=3" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  30. if not defined j for %%b in (%%a) do set "g=%%b" & set "j=1")
  31. ping.exe %g% -n 1
  32. if %errorlevel%==0 (goto:eof) else (echo 网络链接不正常。&pause&exit)
  33. :down
  34. if "%url%"=="a" set down="http://1.exe" "file.exe"
  35. if "%url%"=="b" set down="http://2.exe" "photo.exe"
  36. if "%url%"=="c" set down="http://3.exe" "Psd.exe"
  37. call:Test
  38. (echo on error resume next
  39. echo Download Wscript.Arguments^(0^),Wscript.Arguments^(1^)
  40. echo Sub Download^(url,target^)
  41. echo   Const adTypeBinary = 1
  42. echo   Const adSaveCreateOverWrite = 2
  43. echo   Dim http,ado
  44. echo   Set http = CreateObject^("Msxml2.ServerXMLHTTP"^)
  45. echo   http.open "GET",url,False
  46. echo   http.send
  47. echo   Set ado = createobject^("Adodb.Stream"^)
  48. echo   ado.Type = adTypeBinary
  49. echo   ado.Open
  50. echo   ado.Write http.responseBody
  51. echo   ado.SaveToFile target
  52. echo   ado.Close
  53. echo End Sub)>DownloadFile.vbs||call:usa
  54. echo 正在下载必要组件。
  55. call DownloadFile.vbs %down%
  56. if "%url%"=="a" start /wait file.exe&echo y|copy "%Temp%\~command" "%command%"&goto:eof
  57. if "%url%"=="b" start /wait photo.exe&echo y|copy "%Temp%\~command" "%command%"&goto:eof
  58. if "%url%"=="c" start /wait psd.exe&echo y|copy "%Temp%\~command" "%command%"&goto:eof
  59. del DownloadFile.vbs
  60. set "down="&set "url="&goto:eof
复制代码

cd /d %command%

这条命令改变工作目录,在start之前用
  1. dir & pause
复制代码
检查是否看到要启动的program

TOP

回复 2# ivor


    谢谢你,我知道问题的地方了,安装包是安装在%temp%的目录下但是判断的是当前的目录所以才会一直重复,还有一个问题就是 if not exist 1.exe (start /wait file.exe||Set url=a&call:down) 这段代码如何屏蔽 start 打开错误的讯息,我试过了 >nul 但是没有效果

TOP

屏蔽错误输出句柄:
  1. 2>nul
复制代码

TOP

回复 4# ivor


    这个我知道,就是用start打开,如果打开错误的话会有系统弹窗那个怎么屏蔽,比如 start /wait a.exe||call:down
代码可以正常运行但是如果没有a.exe的话就会错误弹窗。如果用call的话就没有参数wait的了。

TOP

回复 5# 小渣飞
  1. start /wait /min "" "cmd /c a.exe"
复制代码
1

评分人数

TOP

回复 6# ivor


    好哒谢谢你

TOP

返回列表