0

This command is amazing and just what I need. Thank you to who have written it.

I made a bat file that shows all PC details on one screen.... So when I use this command in my bat file it keeps closing.... I have used paused cmd /k etc. etc. and dont work

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 

Below is the command I have and want to run the above disk space check together with mine in one screen without closing the cmd box

@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 :)
2
  • 1
    In batch scripts, % symbols need to be escaped (Doubled) for metavariables such as For loop variables; So %%a instead of %a, %%b not %b etc
    – T3RR0R
    Commented Mar 25, 2021 at 3:03
  • 1
    systeminfo takes a long time, so don't execute it five times. findstr is able to search for mutliple strings in one go: systeminfo |findstr /c:"Domain" /c:"OS Name" /c:"OS Version" /c:<etc>
    – Stephan
    Commented Mar 27, 2021 at 9:57

1 Answer 1

0

In your command line:

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""

In your file bat/cmd multiple lines:

@ 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"

In your file bat/cmd single line:

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""

One suggest unified the all commands in your question, and in one bat:

@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!
3
  • Thank you very much this is working..... but dos box is auto closing ? I did try pause command... /k command etc. Commented Mar 30, 2021 at 17:23
  • @user1288996 Thank you for test and comment. try using timeout -1|echo/Press any key to exit!.
    – Io-oI
    Commented Mar 30, 2021 at 18:07
  • Thank you guys for all the help, much appreciated! Commented Apr 10, 2021 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .