溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何實(shí)現(xiàn)判斷U盤已插入并自動(dòng)COPY所有內(nèi)容的批處理

發(fā)布時(shí)間:2021-10-14 15:22:50 來(lái)源:億速云 閱讀:155 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹如何實(shí)現(xiàn)判斷U盤已插入并自動(dòng)COPY所有內(nèi)容的批處理,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

安裝U盤自動(dòng)復(fù)制.cmd

代碼如下:


@echo off
mode con: cols=80 lines=40
color 17
:start
cls
title $$$$*晗*晗*制*造*$$$$
echo.
echo.
echo.
echo.
echo     ====================================================================
echo.
echo.
echo                              安裝U盤自動(dòng)復(fù)制
echo.
echo                     歡迎使用,請(qǐng)選擇選項(xiàng)(1,2,3,4,5,6)
echo.
echo.
echo                                [1] 安裝程序
echo                                [2] 運(yùn)行程序
echo                                [3] 關(guān)閉程序
echo                                [4] 卸載程序
echo                                [5] 生成快捷方式
echo                                [6] 使用幫助
echo                                [7] X鍵關(guān)閉
echo.
echo.
echo.
echo          提示:如果你計(jì)算機(jī)安裝有殺毒軟件,請(qǐng)授權(quán)此VBS代碼!
echo.
echo.                 
echo.
echo.
echo                          $$$ 晗晗制造,版本1.0 $$$
echo.
echo     ====================================================================
echo.
set /p choice=請(qǐng)輸入:
if {%choice%}=={} goto start
if /i %choice%==1 goto install
if /i %choice%==2 goto open
if /i %choice%==3 goto close
if /i %choice%==4 goto uninstall
if /i %choice%==5 goto shutcut
if /i %choice%==6 goto help
if /i %choice%==x goto shut
goto start



:install
rem ==============================安裝程序=============================
if exist %temp%\copy.cmd del /Q /f "%temp%\copy.cmd"
copy copy.cmd "%temp%\copy.cmd" >nul 2>nul
copy sleep.exe "%temp%\sleep.exe" >nul 2>nul
rem ==============================隱藏窗口=============================
if exist %temp%\hide.vbs del /Q %temp%\hide.vbs
echo.
echo 如果你計(jì)算機(jī)安裝有殺毒軟件,請(qǐng)授權(quán)此VBS代碼
reg delete "HKEY_CLASSES_ROOT\lnkfile" /v IsShortcut /f >nul 2>nul
reg delete "HKEY_CLASSES_ROOT\piffile" /v IsShortcut /f >nul 2>nul
set path=%temp%\copy.cmd
echo set ws=WScript.CreateObject("WScript.Shell") >"%temp%\hide.vbs"
echo ws.Run "%path%",0 >>%temp%\hide.vbs
rem ==============================建立終止=============================
echo @echo off >%temp%\kill.cmd
echo mode con: cols=20 lines=2 >>%temp%\kill.cmd
echo echo                    程序已經(jīng)成功終止!>>%temp%\kill.cmd
echo pause ^>nul 2^>nul >>%temp%\kill.cmd
echo tskill ping ^>nul 2^>nul >>%temp%\kill.cmd
echo tskill xcopy ^>nul 2^>nul >>%temp%\kill.cmd
echo tskill sleep ^>nul 2^>nul >>%temp%\kill.cmd
echo tskill cmd ^>nul 2^>nul >>%temp%\kill.cmd
echo exit ^>nul 2^>nul >>%temp%\kill.cmd
rem ==============================建立快捷=============================
:shutcut
echo.
if not exist "%temp%\hide.vbs" goto start
set path3=%temp%\hide.vbs
echo [InternetShortcut] >>U盤自動(dòng)復(fù)制.url
echo URL="%path3%" >>U盤自動(dòng)復(fù)制.url
echo IconIndex=29 >>U盤自動(dòng)復(fù)制.url
echo IconFile=C:\windows\system32\shell32.dll >>U盤自動(dòng)復(fù)制.url
set path4=%temp%\kill.cmd
echo [InternetShortcut] >>終止U盤自動(dòng)復(fù)制.url
echo URL="%path4%" >>終止U盤自動(dòng)復(fù)制.url
echo IconIndex=29 >>終止U盤自動(dòng)復(fù)制.url
echo IconFile=C:\windows\system32\shell32.dll >>終止U盤自動(dòng)復(fù)制.url
echo 成功結(jié)束!請(qǐng)直接運(yùn)行快捷方式!
pause >nul 2>nul
goto start
rem ==============================安裝結(jié)束=============================


:uninstall
rem ==============================卸載程序=============================
echo.
tskill ping >nul 2>nul
tskill xcopy >nul 2>nul
tskill sleep >nul 2>nul
del /Q /f "%temp%\copy.cmd" >nul 2>nul
del /Q /f "%temp%\hide.vbs" >nul 2>nul
del /Q /f "%temp%\copy.tmp" >nul 2>nul
del /Q /f "%temp%\sleep.exe" >nul 2>nul
del /Q /f "%temp%\kill.cmd" >nul 2>nul
del /Q /f U盤自動(dòng)復(fù)制.url >nul 2>nul
del /Q /f 終止U盤自動(dòng)復(fù)制.url >nul 2>nul
echo 程序已經(jīng)成功卸載!
reg add "HKEY_CLASSES_ROOT\lnkfile" /v IsShortcut /f >nul 2>nul
reg add "HKEY_CLASSES_ROOT\piffile" /v IsShortcut /f >nul 2>nul
pause >nul 2>nul
goto start
rem ==============================卸載結(jié)束=============================


:open
rem ==============================運(yùn)行程序=============================
echo.
if not exist %temp%\copy.cmd goto start
"%temp%\hide.vbs"
echo 程序已經(jīng)成功開始自運(yùn)行(20秒掃描一次)!
pause >nul 2>nul
exit
rem ==============================運(yùn)行結(jié)束=============================



:close
rem ==============================終止程序=============================
echo.
if not exist %temp%\copy.cmd goto start
echo 程序已經(jīng)成功結(jié)束自運(yùn)行!
pause >nul 2>nul
tskill ping >nul 2>nul
tskill xcopy >nul 2>nul
tskill sleep >nul 2>nul
tskill cmd >nul 2>nul
exit
rem ==============================終止結(jié)束=============================




:help
rem ==============================使用幫助=============================
cls
echo.
echo.
echo   本工具適用于Windows XPsp2系統(tǒng),由此造成的一切損失,本人不負(fù)任何責(zé)任.
echo.
echo.
echo   使用方法: 1 點(diǎn)擊安裝程序
echo.
echo             2 如果你計(jì)算機(jī)安裝有殺毒軟件,請(qǐng)授權(quán)此VBS代碼
echo.
echo             3 第一次安裝可能需要先運(yùn)行,然后結(jié)束一次才能生效(視系統(tǒng)設(shè)置而定)
echo.
echo             4 安裝后請(qǐng)用快捷方式啟動(dòng)或者關(guān)閉,無(wú)需用安裝程序啟動(dòng)
echo.
echo             5 本程序可以在U盤插入前運(yùn)行,也可以在插入后運(yùn)行
echo.
echo             6 點(diǎn)擊運(yùn)行程序,程序?qū)⒆詣?dòng)每20秒執(zhí)行一次
echo.
echo             7 請(qǐng)確保你的c:\有足夠的空間,程序運(yùn)行時(shí)候建議不要插移動(dòng)硬盤
echo.
echo             8 請(qǐng)務(wù)必確認(rèn)你要copy的U盤無(wú)毒
echo.
echo             9 本程序在掃描時(shí)比較占內(nèi)存,建議每次使用后關(guān)閉
echo.
echo            10 建立的快捷方式,你可以改名并把它放在任何地方,包括啟動(dòng)菜單
echo.
echo            11 請(qǐng)及時(shí)清理默認(rèn)保存目錄c:\copy文件夾里邊的文件
echo.
echo            12 本軟件不保證copy數(shù)據(jù)的正確性
echo.
echo            13 本軟件不要使用于非法用途
echo.
echo.
echo    本軟件為免費(fèi)軟件歡迎大家使用
echo.
echo    按任意鍵返回主菜單
pause >nul 2>nul
goto start
rem ==============================幫助結(jié)束=============================


:shut
rem ==============================關(guān)閉程序=============================
exit
rem ==============================關(guān)閉結(jié)束=============================


copy.cmd

代碼如下:


@echo off
title $$$$*晗*晗*制*造*$$$$
mode con: cols=14 lines=1
:again
cls
del /Q /f "%temp%\copy.tmp" >nul 2>nul
for %%i 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 @fsutil fsinfo drivetype %%i: >>"%temp%\copy.tmp"
findstr /i "可移動(dòng)驅(qū)動(dòng)器" "%temp%\copy.tmp" 
if errorlevel==1 goto end
if errorlevel==0 goto copy 
:end 
rem 沒(méi)有檢測(cè)到可移動(dòng)磁盤!
if not exist %temp%\sleep.exe ping 127.0.0.1 -n 20 >nul 2>nul
%temp%\sleep.exe 20s
goto again
:copy 
if exist c:\copy goto goon
cd\
cd /d c:
md copy  
:goon 
for /f "tokens=1" %%i in ('findstr /i "可移動(dòng)驅(qū)動(dòng)器" "%temp%\copy.tmp"') do (
xcopy /e /y  %%i\*.* c:\copy >nul 2>nul
)
rem 已復(fù)制,請(qǐng)及時(shí)清理文件!
if not exist %temp%\sleep.exe ping 127.0.0.1 -n 20 >nul 2>nul
%temp%\sleep.exe 20s
goto again

以上是“如何實(shí)現(xiàn)判斷U盤已插入并自動(dòng)COPY所有內(nèi)容的批處理”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI