Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 131,763 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,168 people online right now. Registration is fast and FREE... Join Now!




need help with vbscript arguments.item

 
Reply to this topicStart new topic

need help with vbscript arguments.item, vbscript agruments.item

dmcollette664
post 11 Oct, 2008 - 06:39 AM
Post #1


New D.I.C Head

*
Joined: 13 Sep, 2008
Posts: 13

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

User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 12:58PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month