CMD 命令中的释放空间

CMD 命令中的释放空间

这个命令太棒了,正是我所需要的。感谢编写它的人。

我制作了一个 bat 文件,可以在一个屏幕上显示所有 PC 详细信息....因此,当我在 bat 文件中使用此命令时,它一直关闭....我已经使用暂停的 cmd /k 等,但不起作用

for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%b" ^& " free=" ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& " GiB"^& " size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nologo %temp%\tmp.vbs & del %temp%\tmp.vbs 

下面是我的命令,我想在一个屏幕中同时运行上述磁盘空间检查,而无需关闭 cmd 框

@color 1F
@echo off
wmic.exe BIOS Get Manufacturer,SERIALNUMBER && wmic baseboard get product,serialnumber && WMIC CSPRODUCT GET NAME,version && hostname &&  ipconfig | find /i "IPv4" && echo %username%
systeminfo | findstr /c:"Domain"
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"System type"
systeminfo | findstr /c:"Total Physical Memory"
wmic cpu get name 
THIS LINE i WANT THE COMMAND THAT SHOWS THE HDD'S, FREE SPACE, SIZE IN GB PLEASE :)

答案1

在您的命令行中:

for /f tokens^=1-3 %a in ('"wmic LogicalDisk get FreeSpace,Name,Size|Findstr :"')do  @cmd/q/r >"%tmp%\tmp_vbs.vbs" set/p "'=wsh.echo "%b" & " free=" & FormatNumber(cdbl(%a)/1024/1024/1024, 2)& " GiB"& " size=" & FormatNumber(cdbl(%c)/1024/1024/1024, 2)& " GiB""<nul & @cscript //nologo "%tmp%\tmp_vbs.vbs" & del /q /f /a: "%tmp%\tmp_vbs.vbs""

在您的文件 bat/cmd 中有多行:

@ echo off 

for /f tokens^=1-3 %%a in ('"wmic LogicalDisk get FreeSpace,Name,Size|Findstr :"')do >"%tmp%\tmp_vbs.vbs" (
    set/p "'=wsh.echo "%%b"&" free="& FormatNumber(cdbl(%%a)/1024/1024/1024, 2)&" GiB"&" size= "&FormatNumber(cdbl(%%c)/1024/1024/1024, 2)& " GiB"" 
    ) <nul & cscript //nologo "%tmp%\tmp_vbs.vbs"

2>nul del /q /f /a: "%tmp%\tmp_vbs.vbs"

在您的文件 bat/cmd 中单行:

for /f tokens^=1-3 %%a in ('"wmic LogicalDisk get FreeSpace,Name,Size|Findstr :"')do cmd/q/r >"%tmp%\tmp_vbs.vbs" set/p "'=wsh.echo "%%b" & " free=" & FormatNumber(cdbl(%%a)/1024/1024/1024, 2)& " GiB"& " size=" & FormatNumber(cdbl(%%c)/1024/1024/1024, 2)& " GiB""<nul & %__AppDir__%cscript.exe //nologo "%tmp%\tmp_vbs.vbs" & del /q /f /a: "%tmp%\tmp_vbs.vbs""

建议将问题中的所有命令统一到一个命令中:

@echo off 

color 1F &(
%__AppDir__%wbem\wmic.exe bios Get Manufacturer,SerialNumber
%__AppDir__%wbem\wmic.exe BaseBoard get Product,SerialNumber
%__AppDir__%wbem\wmic.exe CSProduct Get Name,Version)|findstr [a-z-0-9]

for /f useback^tokens^=* %%i in (`"%__AppDir__%hostname.exe"`)do <nul set/p "'=HostName %%i"

for /f tokens^=2delims^=^:  %%i in ('"%__AppDir__%ipconfig.exe |%__AppDir__%find.exe "IPv4""
    ')do echo\ & <nul set/p "'=IPv4 %%~i"<nul & echo\ & echo\UserName %UserName%

for %%i in ("Domain","OS.Name","OS.Version","System type","Total.Physical.Memory"
    )do %__AppDir__%systeminfo.exe | %__AppDir__%findstr.exe "%%~i"
    
for /f tokens^=1*useback %%i in ('"%__AppDir__%wbem\wmic.exe cpu get name /value|findstr [a-z-0-9]"
    ')do echo=CPU Name %%i

for /f tokens^=1-3 %%a in ('"wmic LogicalDisk get FreeSpace,Name,Size|Findstr :"')do >"%tmp%\tmp_vbs.vbs" (
    set/p "'=wsh.echo "%%b"&" free="& FormatNumber(cdbl(%%a)/1024/1024/1024, 2)&" GiB"&" size= "&FormatNumber(cdbl(%%c)/1024/1024/1024, 2)& " GiB"" 
    ) <nul & cscript //nologo "%tmp%\tmp_vbs.vbs"

2>nul del /q /f /a: "%tmp%\tmp_vbs.vbs" & %__AppDir__%timeout.exe -1 |echo\ iS dOnE!

相关内容