1

Hi im having an issue with a batch file. im trying to run fsutil and take the user entry of size, name, and location and pass that to cmd to create files...i have copied a piece of code that was on this site but cannot figure out what is wrong ..any help would be much appreciated

    @echo off
echo ************************
echo * SPARSE FILE CREATION *
echo ************************
set /p path=Enter the Path :
set /p fname=Enter the Filename :
set /p fsize=Enter the filesize (in Mb) :
set /a sizeinbytes=fsize*1024*1024
fsutil file createnew %path%\%fname% %sizeinbytes%
fsutil sparse setflag %path%\%fname% 
fsutil sparse setflag %path%\%fname% 0 %sizeinbytes%
pause

1 Answers1

1

I'm trying to run fsutil

'fsutil' is not recognized as an internal or external command, operable program or batch file

Your batch file is broken because you are overriding the path environment variable:

set /p path=Enter the Path :

Use another name for this variable. I like to prefix all my batch variable with _ to avoid this problem.

Corrected batch file:

@echo off
echo ************************
echo * SPARSE FILE CREATION *
echo ************************
set /p _path=Enter the Path :
set /p fname=Enter the Filename :
set /p fsize=Enter the filesize (in Mb) :
set /a sizeinbytes=fsize*1024*1024
fsutil file createnew %_path%\%fname% %sizeinbytes%
fsutil sparse setflag %_path%\%fname% 
fsutil sparse setflag %_path%\%fname% 0 %sizeinbytes%
pause

DavidPostill
  • 162,382