Batch Script shows no output

前端 未结 4 1639
情深已故
情深已故 2021-01-28 14:08

With reference to my previous question and responses received (which can be found here), I am seeking a help regarding a Batch Script. Based on the responses received to above m

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-28 14:51

    Here is a debugging build. You can see that the variables are ending up nul.

    @echo off
    
    setlocal enabledelayedexpansion
    
    ping -n 1 %1 | find "TTL=" > NUL
    IF NOT ERRORLEVEL 1 (
    echo running loop
    FOR /F %%i IN ('wmic /node:%1 computersystem get Name') DO echo (set A=%%i)
    FOR /F %%i IN ('wmic /node:%1 computersystem get Domain') DO echo (set B=%%i)
    FOR /F %%i IN ('wmic /node:%1 computersystem get UserName') DO echo (set C=%%i)
    FOR /F %%i IN ('wmic /node:%1 computersystem get Manufacturer') DO echo (set D=%%i)
    
    FOR /F "delims=" %%i IN ('wmic /node:%1 computersystem get Model') DO echo (set E=%%i)
    FOR %%a in (!E!) DO echo (set E=%%a)
    
    FOR /F %%i IN ('wmic /node:%1 computersystem get SystemType') DO echo (set F=%%i)
    FOR /F %%i IN ('wmic /node:%1 bios get SerialNumber') DO echo (set G=%%i)
    
    FOR /F "delims=|" %%i IN ('wmic /node:%1 os get Name') DO echo (set H=%%i)
    FOR %%a in (!H!) DO echo (set H=%%a)
    
    FOR /F %%i IN ('wmic /node:%1 os get TotalVisibleMemorySize') DO echo (set J=%%i)
    FOR /F "delims=" %%i IN ('wmic /node:%1 cpu get Name') DO echo (set K=%%i)
    FOR %%a in (!K!) DO echo (set K=%%a)
    
    echo !A!,!B!,!C!,!D!,!E!,!F!,!G!,!H!,!J!,!K! >> output.csv
    
    )
    pause
    

提交回复
热议问题