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

[系统相关] 批处理如何把移动硬盘名或者指定U盘名的文件复制到指定目录?

想说实现一个功能,用作封装系统后继更新软件
运行1.bat
实现功能如下:
1、找到机器上所有盘符里含有sysadmin的(包含本地硬盘,移动硬盘,U盘,存储卡之类的)分区名
2、匹配到后,在名为sysadmin分区下找到soft目录
3、将soft目录复制到本地硬盘,如有D盘
4、复制完后,执行D:\soft\start.bat

回复 1# besunny


    如果有多个盘符里含有sysadmin如何处理?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或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

回复 1# besunny


test-1.bat
  1. @echo off
  2. for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
  3.     if exist %%a:\ (
  4.         vol %%a: | findstr /i "sysadmin" >nul
  5.         if not errorlevel 1 (
  6.             if exist "%%a:\soft" (
  7.                 xcopy /e /y "%%a:\soft" "D:\soft\"
  8.                 start "" "D:\soft\start.bat"
  9.             )
  10.             goto :eof
  11.         )
  12.     )
  13. )
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 1# besunny


test-2.bat
  1. @echo off
  2. for /f "tokens=2 delims==" %%a in ('wmic LogicalDisk where "VolumeName like '%%SYSADMIN%%'" get DeviceID /value') do (
  3.     for %%b in (%%a) do (
  4.         if exist "%%b\soft" (
  5.             xcopy /e /y "%%b\soft" "D:\soft\"
  6.             start "" "D:\soft\start.bat"
  7.         )
  8.         goto :eof
  9.     )
  10. )
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

膜拜大神@Bathcer

TOP

返回列表