@echo off & setlocal EnableDelayedExpansion :start cls echo =============================================================== echo 說 明 echo 使用此批處理可以創(chuàng)建特殊文件夾,使文件夾通過常規(guī)的方法無法 echo 瀏覽、刪除;以實(shí)現(xiàn)簡單加密及防止重要資料誤刪除。 echo 使用方法: echo 1.直接拖動文件夾到該批處理文件圖標(biāo)上。實(shí)現(xiàn)加密、刪除及瀏覽 echo 2.運(yùn)行該批處理,根據(jù)菜單選擇操作. echo 3.將批處理添加到"發(fā)送到"菜單,直接在文件夾點(diǎn)右鍵"發(fā)送到"實(shí) echo 現(xiàn)操作 echo. echo 文件名:encrypt.exe 0oAdaio0 echo E-mail:zhllangzi@163.com 2010/05/13 echo =============================================================== echo. set dir1=%~1 if "%dir1%"=="" goto menu if "%dir1:~-1%"=="." goto 2 cd /d %dir1% if errorlevel 1 goto 3 cd.. call :getdir echo 正在加密"%dirname%"文件夾... ren "%dir1%" "%dirname%../" echo 操作完成,按任意鍵退出... pause >nul goto end :2 echo 1.瀏覽"%dir1%"文件夾 echo. echo 2.刪除"%dir1%"文件夾 echo. echo 3.解密"%dir1%"文件夾 echo. echo 4.退出 echo. set ch1= set /p ch1=請選擇: if /i "%ch1%"=="1" goto topen if /i "%ch1%"=="2" goto tdel if /i "%ch1%"=="3" goto exp if /i "%ch1%"=="4" goto end echo 選擇錯誤!按任意鍵請重新選擇! pause >nul goto 2 :topen explorer "%dir1%.\\" goto end :tdel echo 正在刪除"%dir1%"文件夾 set ch2= set /p ch2=確認(rèn)刪除?[y|n] if /i "%ch2%"=="y" goto ydel if /i "%ch2%"=="n" goto end echo 選擇錯誤!按任意鍵請重新選擇! pause >nul goto tdel :ydel echo 正在刪除... rd "%dir1%.\\" /s /q echo 已成功刪除"%dir1%"文件夾,按任意鍵退出. pause >nul goto end :exp echo 正在解密... call :getdir if exist "%temp%\\~temp.txt" del "%temp%\\~temp.txt" dir "%dir2%" /x | find /i "%dirname%" >"%temp%\\~temp.txt" for /f "tokens=4 delims= " %%i in (%temp%\\~temp.txt) do ( ren "%dir2%%%i" "%dirname:~0,-1%" ) del "%temp%\\~temp.txt" echo 已完成!按任意鍵退出! pause >nul goto end :3 echo 出錯!"%dir1%"不是有效的文件夾. echo 按任意鍵退出! pause >nul goto end :menu echo 1.創(chuàng)建加密文件夾 echo. echo 2.瀏覽文件夾 echo. echo 3.刪除文件夾 echo. if not exist "%userprofile%\\sendto\\加密文件夾.exe" ( echo 4.添加到"發(fā)送到"菜單 ) else ( echo 4.從"發(fā)送到"菜單刪除 ) echo. echo 5.退出 echo. set ch3= set /p ch3=請選擇: if /i "%ch3%"=="1" goto crt if /i "%ch3%"=="2" goto topn if /i "%ch3%"=="3" goto 2del if /i "%ch3%"=="4" goto sdt if /i "%ch3%"=="5" goto end echo 選擇錯誤!按任意鍵請重新選擇! pause >nul goto menu :crt call :getname echo 正在創(chuàng)建"%dirnm%"文件夾... md "%dirnm%"..\\ echo 創(chuàng)建成功. :isop set isopen= set /p isopen=是否現(xiàn)在打開(1.打開,2.返回,3.退出): if /i "%isopen%"=="1" ( set dir1=%dirnm%. goto topen ) if /i "%isopen%"=="2" goto start if /i "%isopen%"=="3" goto end echo 選擇錯誤!按任意鍵請重新選擇! pause >nul goto isop :topn call :getname set dir1=%dirnm% goto topen :2del call :getname set dir1=%dirnm% goto ydel :sdt if not exist "%userprofile%\\sendto\\加密文件夾.exe" ( echo 正在向"發(fā)送到"菜單添加"加密文件夾.exe"項(xiàng)... copy encrypt.exe "%userprofile%\\sendto\\加密文件夾.exe" echo 添加成功!按任意鍵返回! pause >nul goto start ) else ( echo 正在從"發(fā)送到"菜單刪除"加密文件夾.exe"項(xiàng)... del "%userprofile%\\sendto\\加密文件夾.exe" /a /f /q echo 已經(jīng)刪除!按任意鍵返回! pause >nul goto start ) :getname set dirnm= set /p dirnm=請輸入文件夾名稱: if "%dirnm%"=="" goto getname goto :EOF :getdir for %%i in ("%dir1%") do set dir2=%%~dpi set dirname=!dir1:%dir2%=! set dirname=%dirname:\\=% goto :EOF :end |
|