Jump to content











Photo
- - - - -

Please help me to go ahead ?

cmd winpe boot.wim usb booting multibooting

  • Please log in to reply
19 replies to this topic

#1 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 4 days ago

Hello Everyone..

Thanks 'Wonko' for your great help and support....

DIRUSE /M "C:\Users\Kdeva\Music" "C:\Users\Kdeva\Videos" "C:\Users\Kdeva\Desktop" "C:\Users\Kdeva\Documents" "C:\Users\Kdeva\Downloads" > myvol.log
pause

I have executed above command and It gives following result in form of 'myvol.log' file-

    Size (mb)  Files  Directory
        17.75     21  SUB-TOTAL: C:\USERS\KDEVA\MUSIC
         1.01     29  SUB-TOTAL: C:\USERS\KDEVA\VIDEOS
       245.22    304  SUB-TOTAL: C:\USERS\KDEVA\DESKTOP
         0.09      2  SUB-TOTAL: C:\USERS\KDEVA\DOCUMENTS
     14420.99  14103  SUB-TOTAL: C:\USERS\KDEVA\DOWNLOADS
     14685.06  14459  TOTAL

Now I want to use a variable 'BACKUP_SIZE' that will hold Total size of all folders. .i.e BACKUP_SIZE=14685 MB

 

So how I can set Total Size value to 'BACKUP_SIZE'  ?

 

May be I should use something like this ?

for /F "usebackq tokens=?" %%A in (`find " TOTAL " myvol.log`) do set BACKUP_SIZE=%%A
set BACKUP_SIZE=%BACKUP_SIZE:~x,-y%
set /a BACKUP_SIZE=BACKUP_SIZE+10
echo BACKUP Folder is %BACKUP_SIZE%MB
pause

Any better .cmd way to calculate Total sizes of all above folders ?

 

What value I should use in place of Red Highlighted values ?

I don't understand how you guys read a value within from .txt or .log file ? 

Please provide me some good pages so that I can learn how to get a value within from .txt files ?

 

Thanks & Regards...



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 4 days ago

Well you don't actually need to write to a file (unless you want to).

 

FOR /F "tokens=1 delims=. " %%A in ('DIRUSE /M "C:\Users\Kdeva\Music" "C:\Users\Kdeva\Videos" "C:\Users\Kdeva\Desktop" "C:\Users\Kdeva\Documents" "C:\Users\Kdeva\Downloads"') DO SET BACKUP_SIZE=%%A

SET BACKUP_SIZE

 

should do nicely, using  the . (dot) and space as delimiters should give you 14685 (without decimal part, i.e. suitable to be used in a SET /A command).

 

Anyway, it is usually a good idea to use the TYPE command in a FOR loop to read such a .log file:

FOR /F "tokens=1 delims=. " %%A in ('TYPE myvol.log') DO SET BACKUP_SIZE=%%A

SET BACKUP_SIZE

 

In both the above there is no need to "find" anything as the BACKUP_SIZE will be given the value of each line first token, and since the value you are looking for is the last one of the output, it will be the one that "remains".

 

Usual references:

http://www.robvanderwoude.com/for.php

http://www.robvander...e.com/ntfor.php

 

:duff:

Wonko


  • devdevadev likes this

#3 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 4 days ago

Thanks for the great explanation. Now I am getting some idea of syntax  used in cmd and it's uses..

 

Now I want to get Drive Letter of a partition having FREE SPACE greater than %BACKUP_SIZE%. i will first look for a partition of Internal Harddisk having Free Space greater than %BACKUP_SIZE%. if no partition of Internal Harddisk have Free Space greater thank %BACKUP_SIZE%, Then I will look for a partition of Removable USB Drives having Free Space greater than %BACKUP_SIZE%. If no partition having Free Space greater than %BACKUP_SIZE%, then It will just open Windows Explorer for Manual Backup...!!!

 

To achieve  above GOAL, Which tool will be best for listing FREE SPACE of partitions ? 



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 4 days ago

Like? :unsure:

https://ss64.com/nt/diskuse.html

https://ss64.com/nt/freedisk.html

 

The "strategy" is however "perplexing".  :dubbio:

 

Automating the decision on WHERE to store a backup.

 

What could possibly go wrong? :unsure:

 

Also - usually - backups are stored in a compressed form.

 

:duff:

Wonko



#5 Zoso_The_Internet_Tard

Zoso_The_Internet_Tard

    Silver Member

  • Advanced user
  • 536 posts
  • Interests:An investigation is underway to determine whether Trump has any ties to America.

Posted 4 days ago

@devdevadev: You're cleared to go ahead.



#6 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 4 days ago

Mostly when I format and re-install Windows in any System then I copy OLD 'Desktop', 'Music', 'Pictures', 'Documents', and 'Download' folder from SYSPART to any other partition within from WinPE environment. I am using 'SMART_AUTO.cmd' in PTN2 of my Removable USB Drive which I call within from 'boot_%BIT%' of Win 10 1703 (can access all hidden partitions of Removable USB Drive). 'SMART_AUTO.cmd' allow me to do many things. As my vision (RP) is going worse . So I want to improve my 'SMART_AUTO.cmd' so that I can do different action just by entering numbers 1,2,3...etc...instead of seeing white screen of File Explorer in WinPE environment. Here I am not backup up Windows. I just want to copy these 5 folders to any safe place for future uses. 

 

Where I can download 'FREEDISK' and 'DISKUSE' tools. Are these tools also compatible with Win 10 'boot.wim' environment ?

 

It's looking I should check free spaces of all Volumes (Volume 0 to Volume x) if a volume have free space greater than %BACKUP_SIZE%, then set it's Drive Letter to 'FREEVOL' variable. How I can get this in one cmd code ?

 

Is there any tool that will show free spaces of volumes in MB  ? DISKPART LIST VOLUME show only Total size *(both in MB and GB ??) but not free spaces.



#7 Atari800XL

Atari800XL

    Member

  • Members
  • 74 posts
  •  
    Netherlands

Posted 4 days ago

I'm sure Rex Conn's excellent Take Command/ TCC/ TCCLE has something for this. I'm sure you've heard of 4DOS etc, TCC just has so much more power than plain old CMD.EXE (and is much easier to learn, and faster to start, also in PE).

 

Maybe, if you have time to spare (and I think you have) you could check out the "runtime" version of TCC, this one's even free of charge!

 

Check here:

https://jpsoft.com/f...953/#post-43931



#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 3 days ago

The mentioned tools are (see the top of the given pages) are either in the 2003 Resource kit or in Server OS's.

BUT:

fsutil volume diskfree c:

 

OR

 

wmic LogicalDisk Where DriveType="3" Get DeviceID,FreeSpace

 

would both do.

 

 

Or you can use a simple DIR:

DIR C:\ /-O /W

or

DIR C:\ /-C /-O /W

the last line will contain available bytes, so it can be used in batch *like*:

 

FOR /F "tokens=3" %A IN ('DIR C:\ /-C /-O /W') DO SET FREE_SPACE=%%A
)
ECHO FREE_SPACE is %FREE_SPACE%

 

Of course you will need to do some formatting of the string as the data is in bytes.

 

OR try using the "divide.cmd" here :unsure::
http://reboot.pro/to...deccmd/?p=22754

 

:duff:

Wonko



#9 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 3 days ago

I was looking for LOGIC something like this ? 

@echo off
pushd "%~dp0"
setlocal EnableDelayedExpansion

call :BACKUP_PREP
if exist %FREEDRIVE% SET FREEDRIVE
PAUSE
if exist %FREEDRIVE% call :DO_BACKUP
if not exist FREEDRIVE explorer 
echo SMART BACKUP HAS BEEN DONE !!!
PAUSE


:BACKUP_PREP
SET USERDIR=
FOR /F %%A IN ('DIR "%SYSPART%\Users\" /AD /B 2^>nul') DO (
if /i not "%%A"=="Public" FOR /F %%B IN ('DIR "%SYSPART%\Users\%%A\" /AD /B 2^>nul ^|FIND /I "Desktop" ') DO (
IF EXIST "%SYSPART%\Users\%%A\Desktop" (
SET USERDIR=%SYSPART%\Users\%%A
)
)
)
SET USERDIR
FOR /F "tokens=1 delims=. " %%A in ('DIRUSE /M "%USERDIR%\Music" "%USERDIR%\Videos" "%USERDIR%\Desktop" "%USERDIR%\Documents" "%USERDIR%\Downloads"') DO SET BACKUP_SIZE=%%A
SET BACKUP_SIZE
pause

for /F "tokens=2-16 delims=:\ " %%A in ('fsutil fsinfo drives') do (
  for %%d in (%%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O) do (
    for /F "tokens=2 delims=:" %%f in ('fsutil volume diskfree %%d: ^| find "of free bytes" ') do @(
      set mb=%%f
      set mb=!mb:~,-3!
      set /A mb /= 1024 >nul
      echo %%d: !mb!
      if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:& goto :EOF
    )
  )
)


:DO_BACKUP
robocopy "%USERDIR%\Music" "%FREEDRIVE%\BACKUP\Music" /E /MT:1
robocopy "%USERDIR%\Videos" "%FREEDRIVE%\BACKUP\Videos" /E /MT:1
robocopy "%USERDIR%\Desktop" "%FREEDRIVE%\BACKUP\Desktop" /E /MT:1
robocopy "%USERDIR%\Pictures" "%FREEDRIVE%\BACKUP\Pictues" /E /MT:1
robocopy "%USERDIR%\Documents" "%FREEDRIVE%\BACKUP\Documents" /E /MT:1
robocopy "%USERDIR%\Downloads" "%FREEDRIVE%\BACKUP\Downloads" /E /MT:1
goto :EOF

But above code does not seems to work properly  if !mb! is less than %BACKUP_SIZE% ?

i am unable to find out where I am doing wrong ? May be Last LOOP have some wrong LOGIC ?

 

Can anybody please help me to work it out ?

 

Thanks & Regards..



#10 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 days ago

Personally I would write:

if NOT !mb! GTR %BACKUP_SIZE%

as:

if !mb! LSS %BACKUP_SIZE%

or - maybe - as:

if !mb! LEQ %BACKUP_SIZE%

But also :

if  %BACKUP_SIZE% GTR  !mb!

might do.

 

But is this the issue? :unsure:

 

Both "main" and each subroutine MUST end with an unconditional  GOTO :EOF

 

What is :w00t::

if not exist FREEDRIVE explorer 

 

 

:duff:

Wonko



#11 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 2 days ago

This seems working as expected.

@echo off
pushd "%~dp0"
setlocal EnableDelayedExpansion

call :BACKUP_PREP
if not "%FREEDRIVE%"=="" mkdir "%FREEDRIVE%\BACKUP" & Explorer.exe "%FREEDRIVE%\BACKUP" & call :DO_BACKUP
if "%FREEDRIVE%"=="" Explorer ,
echo SMART BACKUP HAS BEEN DONE !!!
PAUSE
exit

:BACKUP_PREP
SET USERDIR=
SET BACKUP_SIZE=
SET FREEDRIVE=
FOR /F %%A IN ('DIR "%SYSPART%\Users\" /AD /B 2^>nul') DO (
if /i not "%%A"=="Public" FOR /F %%B IN ('DIR "%SYSPART%\Users\%%A\" /AD /B 2^>nul ^|FIND /I "Desktop" ') DO (
IF EXIST "%SYSPART%\Users\%%A\Desktop" (
SET USERDIR=%SYSPART%\Users\%%A
)
)
)
FOR /F "tokens=1 delims=. " %%A in ('DIRUSE /M "%USERDIR%\Music" "%USERDIR%\Videos" "%USERDIR%\Desktop" "%USERDIR%\Documents" "%USERDIR%\Downloads"') DO SET BACKUP_SIZE=%%A

FOR /F "tokens=2-16 delims=:\ " %%A in ('fsutil fsinfo drives') do (
  FOR %%d in (%%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O) do (
    FOR /F "tokens=2 delims=:" %%f in ('fsutil volume diskfree %%d: ^| find "of free bytes" ') do @(
      set mb=%%f
      set mb=!mb:~,-3!
      set /A mb /= 1024 >nul
      echo %%d: !mb!
      if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:&goto :EOF
    )
  )
goto :EOF
)

:DO_BACKUP
robocopy "%USERDIR%\Music" "%FREEDRIVE%\BACKUP\Music" /E /MT:1
robocopy "%USERDIR%\Videos" "%FREEDRIVE%\BACKUP\Videos" /E /MT:1
robocopy "%USERDIR%\Desktop" "%FREEDRIVE%\BACKUP\Desktop" /E /MT:1
robocopy "%USERDIR%\Pictures" "%FREEDRIVE%\BACKUP\Pictues" /E /MT:1
robocopy "%USERDIR%\Documents" "%FREEDRIVE%\BACKUP\Documents" /E /MT:1
robocopy "%USERDIR%\Downloads" "%FREEDRIVE%\BACKUP\Downloads" /E /MT:1
goto :EOF

Am I still using something improper or Invalid syntax ? Any improvements ?



#12 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 days ago

I doubt that it actually works (you have the GOTO :EOF of :BACKUP_PREP inside a FOR loop).

 

There is in practice NO error control of any kind, if you are happy with it, by all means go ahead, but given it is something that can - at least in theory - overfill a volume or however copy large amounts of data (presumably important) before throwing a fit (for *whatever* reasons) AND - potentially - overwrite previous backups I would not trust it at all.

 

If (when) it works, the batch first backups those folders to an automatically (random?) selected disk, then tells you that it succeeded (maybe) or "nothing" if it failed, not exactly something I would like to run.

 

This is only "style", but in batch there is the ELSE, so you normally write:

IF condition=true do_this ELSE do_that

as opposed to:

IF condition=false do_that

IF condition=true do_this

 

:duff:

Wonko



#13 paraglider

paraglider

    Gold Member

  • .script developer
  • 1699 posts
  • Location:NC,USA
  •  
    United States

Posted A day ago

You assume there is only one user which is not Public with  desktop folder. That is not true in my case.

 

Also profile folders may not be in their default location and in none english os will have different names as well.

 

Think you should back up all users with desktop folder and include the user name in the backup folder structure.

 

I think

 

if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:&goto :EOF

 

should be:

 

if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:&goto :DO_BACKUP


  • devdevadev likes this

#14 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A day ago

Either of these:

@ECHO OFF
SETLOCAL

FOR /F "tokens=1,2 delims=\ " %%A in ('fsutil fsinfo drives^|find /v""') do CALL :Parse_drives %%A %%B
SET ALLDrives
GOTO :EOF


:Parse_drives
IF NOT %2.==. SHIFT
SET AllDrives=%Alldrives% %1
GOTO :EOF
@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /F "delims=" %%A in ('fsutil fsinfo drives^|find /v""') do (
SET ThisDrive=%%A
SET AllDrives=!Alldrives! !ThisDrive:~-3,2!
)

SET ALLDrives

will list all drives (unless the original code limited to variables A-O, i.e. 15 drives.

 

On newer OS (on XP it throws a warning and a Continue/Retry/Cancel popup when it finds CD's and Card Readers, i.e. "drives" WITHOUT media inserted) this might even work:

@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /F "delims=" %%A in ('fsutil fsinfo drives^|find /v""') do SET AllDrives=!Alldrives! %%~dA

SET ALLDrives

:duff:

Wonko



#15 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted A day ago

Think you should back up all users with desktop folder and include the user name in the backup folder structure.

 

I think

 

if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:&goto :EOF

 

should be:

 

if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:&goto :DO_BACKUP

Thanks for the necessary suggestions...

@echo on
pushd "%~dp0"
setlocal EnableDelayedExpansion

call :BACKUP_PREP
if "%FREEDRIVE%"=="" Explorer ,
echo SMART BACKUP HAS BEEN DONE !!!
PAUSE
exit


:BACKUP_PREP
SET USER=
SET USERDIR=
FOR /F %%A IN ('DIR "C:\Users\" /B 2^>nul') DO (
if /i not "%%A"=="Public" FOR /F %%B IN ('DIR "C:\Users\%%A\" /B 2^>nul ^|FIND /I "Desktop" ') DO (
IF EXIST "C:\Users\%%A\Desktop" (
SET USER=%%A& SET USERDIR=C:\Users\%%A
call :BACKUP_SIZE

FOR /F "tokens=2-16 delims=:\ " %%A in ('fsutil fsinfo drives') do (
  FOR %%d in (%%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O) do (
    FOR /F "tokens=2 delims=:" %%f in ('fsutil volume diskfree %%d: ^| find "of free bytes" ') do @(
      set mb=%%f
      set mb=!mb:~,-3!
      set /A mb /= 1024 >nul
      echo %%d: !mb!
      SET BACKUP_SIZE
      if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:& call :DO_BACKUP
    )
  )
)
    )
  )
)

:BACKUP_SIZE
FOR /F "tokens=1 delims=. " %%A in ('DIRUSE /M "%USERDIR%\Music" "%USERDIR%\Videos" "%USERDIR%\Desktop" "%USERDIR%\Documents" "%USERDIR%\Downloads"') DO SET BACKUP_SIZE=%%A
goto :EOF

:DO_BACKUP
mkdir "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%" & Explorer.exe "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%"
robocopy "%USERDIR%\Music" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Music" /E /MT:1
robocopy "%USERDIR%\Videos" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Videos" /E /MT:1
robocopy "%USERDIR%\Desktop" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Desktop" /E /MT:1
robocopy "%USERDIR%\Pictures" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Pictures" /E /MT:1
robocopy "%USERDIR%\Documents" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Documents" /E /MT:1
robocopy "%USERDIR%\Downloads" "%FREEDRIVE%\BACKUP_%USER%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%\Downloads" /E /MT:1
goto :EOF

Why following line does not utilize value of %BACKUP_SIZE% in above codes ?

if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:& call :DO_BACKUP

Other things looking working except it ? Where I am doing WRONG ?

 

Regards..



#16 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A day ago

Do you really expect that someone will run your batch to find why it doesn't work?

 

Your batch is too convoluted .

 

Make it simpler.

 

You have 3 actions to perform:

1) determine the path and size to be backed up -> this will output "Backup_size"

2) determine which (first? :w00t:) volume that has enough free space to receive the backup -> this will output the target volume, i.e. "FreeDrive"

3) do the backup.

 

This can be written more easily as three separate, self-standing batches.

 

Do that.

 

When each of the three batches works, then (and only then) you can consolidate them in a single batch.

 

The issue you are having is likely connected with the delayed expansion, you have 6 levels of brackets/FOR loops.

 

Simplify.

 

Put some PAUSE's displaying the values



echo %%d: !mb!
SET mb
ECHO BackupSize %BACKUP_SIZE%
SET BACKUPSIZE
ECHO if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=%%d:
PAUSE

:duff:

Wonko



#17 paraglider

paraglider

    Gold Member

  • .script developer
  • 1699 posts
  • Location:NC,USA
  •  
    United States

Posted 19 hours ago

There are also many other scripting languages you could use which would make your job easier once you learn the language - autoit / vbscript to name 2. Powershell is also a very powerful language but does require .NET.

 

Yes you can probably get it working with a batch file but they are very painful to debug and usually become very difficult to understand later even for the person who wrote them.



#18 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13574 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 16 hours ago

There are also many other scripting languages you could use which would make your job easier once you learn the language - autoit / vbscript to name 2. Powershell is also a very powerful language but does require .NET.

 

Yes you can probably get it working with a batch file but they are very painful to debug and usually become very difficult to understand later even for the person who wrote them.

Sure :), once you have learned them, and JFYI, I can read and understand just fine batches I wrote  some 20+ years ago, maybe I am an exception :dubbio:

 

:duff:

Wonko


  • devdevadev likes this

#19 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 352 posts
  •  
    India

Posted 2 hours ago

This display Drive Letter and it's free spaces *(in MB). 

for /F "tokens=2-16 delims=:\ " %%A in ('fsutil fsinfo drives') do (
  for %%d in (%%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O) do (
    for /F "tokens=2 delims=:" %%f in ('fsutil volume diskfree %%d: ^| find "of free bytes" ') do @(
      set mb=%%f
      set mb=!mb:~,-3!
      set /A mb /= 1024 >nul
      echo %%d: !mb!
    )
  )
) 

But how can I get Drive Letter of Disk Volume having maximum FREE SPACE *(in MB) using batch file ? 



#20 cdob

cdob

    Gold Member

  • Expert
  • 1324 posts

Posted An hour ago

Which windows version do you use?
'fsutil fsinfo drives' does not print spaces between the drive list, fsutil prints 0x0 instead.
Use a work arround to change the 0x0 byte.
 
set first=true
FOR /F "tokens=1-2* delims=\ " %%a in ('fsutil fsinfo drives ^| more') do (
  if not defined first set drive=%%a
  if defined first ( set drive=%%b &set first=)
  echo !drive!
  
  FOR /F "tokens=2 delims=:" %%f in ('fsutil volume diskfree !drive! ^| find "of free bytes" ') do @(
    set mb=%%f
    set mb=!mb:~,-3!
    set /A mb /= 1024 >nul
    echo !drive! !mb!
    SET BACKUP_SIZE
    if !mb! GTR %BACKUP_SIZE% set FREEDRIVE=!drive!& set FREEDRIVE
  )
)






Also tagged with one or more of these keywords: cmd, winpe, boot.wim, usb booting, multibooting

3 user(s) are reading this topic

2 members, 1 guests, 0 anonymous users


    devdevadev, steve6375