troubleshooting Question

VB Script to do an unattended format of a drive

Avatar of BenthamLtd
BenthamLtd asked on
Visual Basic Classic
8 Comments1 Solution1427 ViewsLast Modified:
I am trying to write a VB script to do an unattended quick format of a drive. I can get the format box to appear but i can't get it to autostart and complete. Ideally I just want a message to say that its done.  Listed below is the code i have used

Private Declare Function SHFormatDrive Lib "Shell32.dll" (ByVal hWnd As Long, _
    ByVal Drive As Integer, ByVal fmtID As Integer, ByVal Options As Integer) _
    As Long

Private Sub Command1_Click()
Dim ret As Long
ret = SHFormatDrive(hMainWnd, 6, -1, 1)
End Sub

Does anyone have any ideas? I would also like to be able to specify a volume name?

Many thanks,

Mark
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros