I am an IT Trainer and am preparing some disk images for our students to use in troubleshooting labs. I need a script that I can run that will query the freespace on c: save the result to a variable that is then passed to fsutil to create a file filling up the hard disk. (my students need to identify that the 'user' cannot save a file because the hard disk space is exhausted. I am not a programmer but have managed to stitch together the following script from various places.
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
FileSize = objLogicalDisk.FreeSpace
Wscript.Echo FileSize
Set fso = CreateObject("Scripting.FileSystemObject")
set shl = createobject("wscript.shell")
shl.run "fsutil file createnew C:\incredible.hlk" FileSize,0,true
The wscript.echo filesize is showing the freespace so I am confident that the problem lies in the last line.
Could anyone offer me any advice on where I am going wrong?
Kind regards
Trevor
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
FileSize = objLogicalDisk.FreeSpace
Wscript.Echo FileSize
Set fso = CreateObject("Scripting.FileSystemObject")
set shl = createobject("wscript.shell")
shl.run "fsutil file createnew C:\incredible.hlk" FileSize,0,true
The wscript.echo filesize is showing the freespace so I am confident that the problem lies in the last line.
Could anyone offer me any advice on where I am going wrong?
Kind regards
Trevor