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

[文件操作] [已解决]求助修改安装FileZilla Server的批处理

  1. @echo off
  2. if exist "C:\Progra~2\FileZilla Server\FileZilla Server.xml" (
  3. goto install86
  4. ) else (
  5. goto install64
  6. )
  7. :install86
  8. del /s /q /f "C:\Progra~2\FileZilla Server\FileZilla Server.xml
  9. move "%~dp0\FileZilla Server.xml" "C:\Progra~2\FileZilla Server"
  10. NET STOP "FileZilla Server"&&NET START "FileZilla Server"
  11. goto allinstallok
  12. :install64
  13. if exist "C:\Progra~1\FileZilla Server\FileZilla Server.xml" (
  14. goto installin
  15. ) else (
  16. goto out
  17. )
  18. :installin
  19. del /s /q /f "C:\Progra~1\FileZilla Server\FileZilla Server.xml
  20. move "%~dp0\FileZilla Server.xml" "C:\Progra~1\FileZilla Server"
  21. NET STOP "FileZilla Server"&&NET START "FileZilla Server"
  22. goto allinstallok
  23. :allinstallok
  24. echo. >>ipaddress.txt
  25. echo. >>ipaddress.txt
  26. echo 程序部署完成 >>ipaddress.txt
  27. echo. >>ipaddress.txt
  28. echo 以下为本机IP信息,请拍照或者记录 >>ipaddress.txt
  29. echo. >>ipaddress.txt
  30. echo ------------------------------------------------------>>ipaddress.txt
  31. echo. >>ipaddress.txt
  32. ipconfig | findstr "IPv4 地址">>ipaddress.txt
  33. echo. >>ipaddress.txt
  34. echo ------------------------------------------------------>>ipaddress.txt
  35. start notepad "ipaddress.txt"
  36. ping /n 2 127.1>nul
  37. del /q ipaddress.txt
  38. ver|findstr "5.1" >nul && (
  39.     set "m=ipconfig^|findstr /i "ip address""
  40. )|| (
  41.     set "m=ipconfig^|findstr /i "ipv4""
  42. )
  43. for /f "tokens=14* delims=: " %%1 in ('%m%')do start "" "ftp://%%2:18003"
  44. set /p clean="是否需要清理安装文件 Y / N ?"
  45.     if /i "%clean%"=="Y" cd /d ... & rd /s /q "%~dp0"
  46.     if /i "%clean%"!="Y" exit
  47. :out
  48. echo.
  49. echo.
  50. echo                            没有找到安装文件,请确认是否已完成安装
  51. echo.
  52. pause
复制代码
问题1:有的电脑能运行,有的不能运行,直接跳到OUT 提示 没有找到安装文件,请确认是否已完成安装.
问题2:无法删除文件夹本身
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

回复 1# newgain


:install64
if exist "C:\Progra~1\FileZilla Server\FileZilla Server.xml" (
goto installin
) else (
goto out
)

跳转到ut说明执行这段代码的时候,if判断找不到文件 "C:\Progra~1\FileZilla Server\FileZilla Server.xml"
是不是你的代码逻辑写错啦?为啥不存在这个文件就要 goto out 呢?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 2# Batcher
默认的安装文件夹呀

TOP

回复 3# newgain


在出问题的机器上:
把Progra~2和Progra~1这种短名都改成完成名称再执行试试,并确认一下C:\xxx\FileZilla Server\FileZilla Server.xml 这个文件到底真的存在还是不存在
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 4# Batcher

回头我再试试。这个文件应该是存在的,安装完才会运行这个批处理,就是觉得替换配置文件重启服务器太麻烦才写的这个。
删除文件夹的代码好像是有问题的,无法删除文件夹

TOP

回复  newgain


:install64
if exist "C:\Progra~1\FileZilla Server\FileZilla Server.xml" (
goto ...
Batcher 发表于 2019-10-23 17:08



    不存在这个文件说明 软件安装包没有安装,所以退出批处理

TOP

回复 6# newgain


    那你的问题1就不是问题了吧。这个代码准确完成了你的这个说法
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. @echo off
  2. if exist "C:\Program Files (x86)\FileZilla Server\FileZilla Server.xml" (
  3. goto install64
  4. ) else (
  5. goto install86
  6. )
  7. :install86
  8. if exist "C:\Program Files\FileZilla Server\FileZilla Server.xml" (
  9. goto installin
  10. ) else (
  11. goto out
  12. )
  13. :install64
  14. del /s /q /f "C:\Program Files (x86)\FileZilla Server\FileZilla Server.xml
  15. move "%~dp0\FileZilla Server.xml" "C:\Program Files (x86)\FileZilla Server"
  16. NET STOP "FileZilla Server"&&NET START "FileZilla Server"
  17. goto allinstallok
  18. :installin
  19. del /s /q /f "C:\Program Files\FileZilla Server\FileZilla Server.xml
  20. move "%~dp0\FileZilla Server.xml" "C:\Program Files\FileZilla Server"
  21. NET STOP "FileZilla Server"&&NET START "FileZilla Server"
  22. goto allinstallok
  23. :allinstallok
  24. echo. >>ipaddress.txt
  25. echo. >>ipaddress.txt
  26. echo 程序部署完成 >>ipaddress.txt
  27. echo. >>ipaddress.txt
  28. echo 以下为本机IP信息,请拍照或者记录 >>ipaddress.txt
  29. echo. >>ipaddress.txt
  30. echo ------------------------------------------------------>>ipaddress.txt
  31. echo. >>ipaddress.txt
  32. ipconfig | findstr "IPv4 地址">>ipaddress.txt
  33. echo. >>ipaddress.txt
  34. echo ------------------------------------------------------>>ipaddress.txt
  35. start notepad "ipaddress.txt"
  36. ping /n 2 127.1>nul
  37. del /q ipaddress.txt
  38. ver|findstr "5.1" >nul && (
  39.     set "m=ipconfig^|findstr /i "ip address""
  40. )|| (
  41.     set "m=ipconfig^|findstr /i "ipv4""
  42. )
  43. for /f "tokens=14* delims=: " %%1 in ('%m%')do start "" "ftp://%%2:18003"
  44. set /p clean="是否需要清理安装文件 Y / N ?"
  45.     if /i "%clean%"=="Y" cd /d ...&rd /s /q %~dp0
  46.     if /i "%clean%"!="Y" exit
  47. :out
  48. echo.
  49. echo.
  50. echo                            没有找到安装文件,请确认是否已完成安装
  51. echo.
  52. pause
复制代码
修改了一下,本机测试没问题,自动清理安装程序也没问题了

TOP

返回列表