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!

Dos help

Status
Not open for further replies.

GrimR

IS-IT--Management
Jun 17, 2007
1,149
ZA
I know its the wrong place but is there a DOS section


What I am trying to do is get a list of drives
e.g
fsutil fsinfo drives
which returns
Drives: A:\ C:\ D:\ F:\ H:\ K:\ L:\ M:\ N:\ O:\ P:\ Q:\ T:\ X:\ Z:then I need to remove a directory from each drive hopefully the above can be used as an array.
FOR /F "delims= " %%G IN (Drives) DO somethinglikebelow %%G
e.g.
Attrib -s -r -h in Drives: DirctoryName
RD Drives: DirectoryName

any help appreciated even if it has to be done in vbscript


MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Please help with array, it works if I have a single folder.

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives

sfolder = Array(":\folder1", ":\folder2")

For Each objDrive in colDrives
	
		If objFSO.FolderExists(objDrive.DriveLetter & sfolder) Then
		
				wscript.echo objDrive.DriveLetter & sfolder
				objFSO.DeleteFolder(objDrive.DriveLetter & sfolder),DeleteReadOnly
	Else

				wscript.echo "nothing"

		End If
Next

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
sfolder[!]s[/!] = Array(":\folder1", ":\folder2")
For Each objDrive in colDrives
    [!]For Each sfolder in sfolders[/!]
	If objFSO.FolderExists(objDrive.DriveLetter & sfolder) Then
				wscript.echo objDrive.DriveLetter & sfolder
				objFSO.DeleteFolder(objDrive.DriveLetter & sfolder),DeleteReadOnly
	Else
				wscript.echo "nothing"
	End If
    [!]Next[/!]
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV
Now get an error

Object not a collection 800A01C3
Think it has something to do with missing something like this Set sFolder = objFSO.GetFolder
Am I on the right track

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Getting closer how can I prevent it from checking A: or suppressing errors altogether

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
on error resume next
afolder = Array("Folder1", "Folder2")

For Each objDrive in colDrives
    For Each sfolder in afolder
		Set sFolder = objFSO.GetFolder(sfolder)
		If objFSO.FolderExists(objDrive.DriveLetter & ":\" & sfolder) Then
				wscript.echo objDrive.DriveLetter & ":\" & sfolder
				'objFSO.DeleteFolder(objDrive.DriveLetter & sfolder),DeleteReadOnly
			Else
				wscript.echo "nothing"
		End If
    Next
Next

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Set sFolder = objFSO.GetFolder(sfolder)
What is the meaning of that unsane statement ?????

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top