This is my 346th attempt (or atleast it feels that way). I read the book, browsed through windows script technologies HELP system.
Here is what my program is SUPPOSE to do.
-check for parameter ( only one, else leave error msg). end
-check to see if that drive (parameter entered by user) exists else error msg, end
-check to see if that drive is ready else error msg, end
-check for subfolders on the root of that drive if non exist error msg, end
-if there are subfolders, display them (no more than 20 per msgbox),
-use inputbox to get user's choice of folder
-check to see if files exist in that folder, if exist - show list of files, else error message, end
CODE
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~ Assignment45.vbs ~
'
'Crystal T
'April 27th, 2007
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Explicit
'Declare Variables
Dim args, mydrive, fsoobject, disk, check
Dim folder, subfold, f, fl, fc, s
Const ErrorBar="Error!"
' Make sure the user entered only ONE parameter and assign that to the variable name "drive"
Set args=Wscript.arguments
If args.count<>1 Then
MsgBox "You can only enter one, and only ONE drive letter!.", 48 , ErrorBar
Else
mydrive=args.item(0)
End If
'Check for Drive existance
Set fsoobject=WScript.CreateObject("Scripting.FileSystemObject")
Set disk=fsoobject.getdrive (mydrive)
If fsoobject.DriveExists(disk) Then
MsgBox "Drive " & disk & " does exist!", vbOKOnly , "The Drive Exists!"
Else
MsgBox "The drive does not exist!", 48, ErrorBar
End If
'Check to see if Drive is ready
If disk.IsReady Then
MsgBox "Drive " & disk & " is ready!", vbOKOnly, "Its ready!"
Else
MsgBox "The Drive is NOT ready!", 48, ErrorBar
End If
'Check for existance of subfolders and list them
Set folder=fsoobject.GetFolder(disk.RootFolder)
If fsoobject.FolderExists(subfold) Then
MsgBox "There are subfolders!", 48, ErrorBar
End If
Set subfold=fsoobject.GetFolder(folder.SubFolders)
If fsoobject.FolderExists(subfold) Then
MsgBox "That folder exists! Here comes the list of files for that folder"
End If
'Get subfolder name from user
check=InputBox("Please enter the name of the subfolder's files you'd like to see")
If fsoobject.FolderExists(check) Then
Set f = fsoobject.GetFolder(check)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFileList = s
Then
MsgBox showfilelist
Else
MsgBox ("There's no files in that folder! Bye!"), vbOKOnly, ErrorBar
End If
This post has been edited by crystal_lynn: 27 Apr, 2007 - 07:14 PM