blog.species5618.net

Tag: WMI

Windows WMI shocker

by on Jun.26, 2008, under General

I have been working on a ZERO touch build script for IIS on and off for a few weeks,

One of the last stepping stone for formating the “data” drive prior to setting everything up

“FORMAT H: /FS:NTFS /V:ASG” will prompt for “do you want to erase all yoiu data”, and again if the disk is in use !

So enter WMI, after only 20 mins of digging around the the internet I found some code to do a defrag, a few tweaks, and I have some VBS code that will format a DRIVE, NO questions, even if the drive is in use, and it is ONLY 7 lines

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set colVolumes = objWMIService.ExecQuery (“Select * from Win32_Volume Where Name = ‘H:\\'”)
For Each objVolume in colVolumes
errResult = objvolume.dismount(1,0)
errResult = objVolume.format(“NTFS”, 1, 4096, “ASG”, 0)
Next

Comments Off on Windows WMI shocker :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...