Format disks in WSH

The following script demonstrates how to access the Windows Format dialog box to format a floppy disk. It uses the undocumented SHFormatDrive-command.

'************************************************
' File: WSHFormatDisk.vbs (WSH-sample in VBScript)
' Author: (c) G. Born 
' The script opens the Windows Format dialog to 
' format a floppy disk.
' In no way shall the author be liable for any
' losses or damages resulting from the use of this
' program. Use AS-IS at your own risk.
'
' The code is the property of the author. You may
' use the code and modify it, as far as this header
' remains intact. Further updates and other samples
' may be found on my site:
' http://www.Borncity.de
'************************************************
Option Explicit

Dim WshObj

' Object needed for the Run-Method
Set WshObj = Wscript.CreateObject("WScript.Shell")

WshObj.Run "RunDll32.exe Shell32.dll,SHFormatDrive", _
            1, true ' launch dialog

' End

Additional information about this sample and the way how to call API-functions may be found in my WSH book.

Back