Hello!
I seem to be missing something, like flawed logic or testing - not sure which (maybe both). When I get to the isready for drive c:, I get an error message stating that "object required "c". I am using c as the first parameter. Any help is much appreciated.
Thank you!
CODE
Dim fso,folders,d,dc,files,count,mess,myfolder,mydrive,mypath 'sets variables
Dim ObjWshArgs,file
Set ObjWshArgs = WScript.Arguments 'gets an object
'use the WshArguments object's count property to verify that 2 arguments were received. If not, script is terminated
If ObjWshArgs.Count <= 1 Or ObjWshArgs.Count >= 3 Then
MsgBox "I require exactly (2) two Parameters" 'error message to user when correct parameters not recieved
WScript.Quit 'script terminated
End If
mydrive = ObjWshArgs.Item(0)
myfolder = ObjWshArgs.Item(1)
mypath = mydrive & ":" & "\" & myfolder
'Assign each argument to a variable for processing
Set fso = CreateObject("Scripting.FileSystemObject") 'gets an object
Set dc = fso.Drives
For Each d In dc
If fso.DriveExists(mydrive) Then
fso.GetDrive(mydrive)
Else
MsgBox "Drive " & mydrive & " is not a valid drive."
WScript.Quit
End If
Next
For Each d In dc
fso.GetDrive(mydrive)
If mydrive.isready Then 'tests if drive is ready
Else
MsgBox "Drive " & mydrive & " is not ready."
End If
Next
For Each d In dc
If myfolder.exists Then
Set myfolder = fso.GetFolder(mypath)
Else
MsgBox "Folder " & myfolder & " does not exist."
End If
Next