我在Windows 8.1上。我用隐藏文件/文件夹获取USB。要取消隐藏它们,我使用attrib命令。我想通过简单地插入USB来运行命令。帮助。
echo off
echo Please have patience!!! Wait or Minimise the window!!!
rem c:\script\unhide.bat
@echo off
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (
if %%l equ 2 (
echo %%i is a USB drive.
)
)
Pause
这里我收到了驱动器号H.我无法使用驱动器号并在USB中使用以下命令。我怎么能在USB下面的命令下面运行。我的意思是Change Drive,在USB中运行attrib命令,从USB中删除不需要的文件并查看USB的内容。
cd\
attrib -s -h -r /s /d
del *.lnk
del thumbs.db
del desktop.ini
del autorun.inf
echo Your Folders has been recovered!!! Check your folders and files
dir
pause
exit
答案 0 :(得分:0)
@ECHO OFF
SETLOCAL enableextensions
echo Please have patience!!! Wait or Minimise the window!!!
rem c:\script\unhide.bat
for /F "skip=1 tokens=1-3" %%i in ('
wmic logicaldisk where "drivetype=2" get caption^,drivetype^,SystemName
') do (
if "%%j"=="2" (
echo "%%i" is a USB drive ^(DriveType=%%j^).
pushd "%%i\"
SETLOCAL enabledelayedexpansion
echo current folder !CD!
ENDLOCAL
echo attrib -H -S -T /S /D /L >NUL 2>&1
echo del *.lnk 2>NUL
echo del thumbs.db 2>NUL
echo del desktop.ini 2>NUL
echo del autorun.inf 2>NUL
echo Your Folders has been recovered!!! Check your folders and files
dir
pause
popd
)
)
ENDLOCAL
goto :eof
注意:
wmic
命令更改如下:
where
条款; description
省略,因为此属性的字数不同,因此会中断标记化; SystemName
以传递返回行中的结尾回车符:wmic
behavior =每个输出行以0x0D0D0A
结尾(<CR><CR><LF>
)而非公共0x0D0A
(<CR><LF>
)。对于另一种(一般)方法,请参阅Dave Benham&#39; WMIC
and FOR /F
: A fix for the trailing <CR>
problem; for /F
循环根据更改的wmic
命令(和skip=1
)进行调整; attrib -H -S -T /S /D /L
仅用于echo
以进行调试;除了调试之外删除echo
(所有del
命令都相同); pushd
- popd
对:PUSHD
changes the current directory/folder and stores the previous folder/path for use by the POPD
command; System Volume Information
应保留属性System
&amp; Hidden
如果有的话。