Post problem reports here for Batch files for use in BSOD debugging


  1. Posts : 7,606
    Windows 10 Home 20H2
       #1311

    I did not want DISM to display the following type of results:

    kate1978 said:
    Code:
     [===========================84.9%=================         ]
    
    [===========================86.1%=================         ]
    
    [===========================87.3%==================        ]
    
    [===========================88.7%===================       ]
    
    [===========================89.9%====================      ]
    
    [===========================91.1%====================      ]
    
    [==========================100.0%==========================]
      My Computer


  2. Posts : 1,777
    Windows 11 [21H2]
       #1312

    Matthew Wai said:
    I did not want DISM to display the following type of results:
    Is we can remove that using for /f?
      My Computers


  3. Posts : 7,606
    Windows 10 Home 20H2
       #1313

    In what context should for /f be used?
      My Computer


  4. Posts : 1,777
    Windows 11 [21H2]
       #1314

    Matthew Wai said:
    In what context should for /f be used?
    by this?
    Code:
    for /F "tokens=*" %1 in ('dism /online /cleanup-image /restorehealth') do (echo %1 | findstr /v /c:"[")
    Note   Note
    not tested
      My Computers


  5. Posts : 7,606
    Windows 10 Home 20H2
       #1315

    It will probably not work.
      My Computer


  6. Posts : 1,777
    Windows 11 [21H2]
       #1316

    Matthew Wai said:
    It will probably not work.
    well, it works.
    Code:
    C:\Users\jbcarreon123>for /F "tokens=*" %1 in ('echo test') do (echo %1 | findstr /v /c:"[")
    
    
    C:\Users\jbcarreon123>(echo test   | findstr /v /c:"[" )
    test
    
    C:\Users\jbcarreon123>for /F "tokens=*" %1 in ('echo [') do (echo %1 | findstr /v /c:"[")
    
    
    C:\Users\jbcarreon123>(echo [   | findstr /v /c:"[" )
    
    C:\Users\jbcarreon123>for /F "tokens=*" %1 in ('echo [================100%===============]') do (echo %1 | findstr /v /c:"[")
    
    
    C:\Users\jbcarreon123>(echo [ 100% ]   | findstr /v /c:"[" )
    
    C:\Users\jbcarreon123>for /F "tokens=*" %1 in ('echo [test]') do (echo %1 | findstr /v /c:"[")
    
    
    C:\Users\jbcarreon123>(echo [test]   | findstr /v /c:"[" )
    
    C:\Users\jbcarreon123>
    IF the string does not include [, then it proceeds.
      My Computers


  7. Posts : 7,606
    Windows 10 Home 20H2
       #1317

    It will work only after the whole operation has been completed.
    It will not show the progress while the operation is in progress.
      My Computer


  8. Posts : 7,606
    Windows 10 Home 20H2
       #1318

    jbcarreon123 said:
    Code:
    PowerShell GWMI -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage^|FT -A FriendlyName,@{l='MediaType';e={if ($_.MediaType -eq '0') {'USB'} elseif ($_.MediaType -eq '3') {'HDD'} else {'SSD'}};A='Right'}
    Your code can be somewhat simplified by using switch instead of if + elseif + else as shown below:

    Code:
    PowerShell GWMI -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage^|FT -A FriendlyName,@{l='MediaType';e={switch($_.MediaType){0{'USB'};3{'HDD'};4{'SSD'}}};A='Right'}
      My Computer


  9. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #1319

    jbcarreon123 said:
    . . . try this . . .

    Code:
    PowerShell GWMI -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage^|FT -A FriendlyName,@{l='MediaType';e={if ($_.MediaType -eq '0') {'USB'} elseif ($_.MediaType -eq '3') {'HDD'} else {'SSD'}};A='Right'}

    I modified Matthew's code so it will use SSD instead of 4
    Matthew Wai said:
    Your code can be somewhat simplified by using switch instead of if + elseif + else as shown below:

    Code:
    PowerShell GWMI -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage^|FT -A FriendlyName,@{l='MediaType';e={switch($_.MediaType){0{'USB'};3{'HDD'};4{'SSD'}}};A='Right'}
    BOTH the above Commands report USB on my Laptop when NO USB is connected.
      My Computer


  10. Posts : 7,606
    Windows 10 Home 20H2
       #1320

    Run the following and post the output:

    Code:
    PowerShell GWMI -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage^|Select FriendlyName,MediaType
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:24.
Find Us




Windows 10 Forums