Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format HDD wand keep NTFS permissions

Status
Not open for further replies.

Wazz

Technical User
Aug 12, 2002
209
GB
Hi Everyone,

I have a batch file that formats a HDD and then copys files to it using xcopy, with switches that keep the ntfs permissions.

My problem is, in the batch file, the drive letter is set to C, but I now need the drive letter to be a variable as it could be any letter. (its going to copy to removable media), but I cant find out how to format a drive in vbscript or if its even possible?

A section of my batch file is below

Thanks,
Wazz

label c: XXX

format C: /fs:ntfs /q /v:xxx /y

xcopy z:\xxx\*.* c:\ /s/e/r/c/h/k/o/y
 
I have found a script here
that formats a hard drive using VB script, but it doesnt work. I get the error 80041010, relating to the line:

For Each objVolume In colVolumes

but I cant see whats wrong with the script.

If someone could help out that would be great.
Thanks,
Wazz

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'D:\\'")
For Each objVolume In colVolumes
errResult = objVolume.Format("NTFS")
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top