为什么我在批次上得到一个空的结果我尝试在下面做:
@echo off
setlocal EnableDelayedExpansion
rem empty recycle bin
for /f "delims= " %%a in ('"wmic USERACCOUNT where name="%username%" get sid"') do (
if not "%%a"=="SID" (
set myvar=%%a
)
)
cd %systemdrive%\$Recycle.Bin\!myvar!
echo The directory is change to %systemdrive%\$Recycle.Bin\!myvar!
pause
它没有显示myvar的值
答案 0 :(得分:0)
这是你的脚本修复:
@Echo Off
Rem Empty recycle bin
For /F "Skip=1" %%A In ('WMIC UserAccount Where "Name='%UserName%'"^
Get SID 2^>Nul') Do For %%B In (%%A) Do Set "MyVar=%%B"
CD /D "%SystemDrive%\$Recycle.Bin\%MyVar%" 2>Nul || Exit /B
Echo The directory has been changed to %CD%
Pause