I now have a script which needs to access the root folder of a user defined
drive in order to test for the existance of sub folders. I am having no luck
getting access to the root folder of the selected drive. Is the 'getfolder'
method the wrong thing to be using for this? The script looks like this:
Dim WshShl, iconyn, dtop, scut, dltr, argobj, fso, dready
Dim path, fold, subf
'Get User Input For Desktop Icon Creation
set WshShl = WScript.CreateObject("WScript.Shell")
iconyn = WshShl.Popup("Would you like a shortcut for this script"_
& " created on your desktop?",,"User Input",36)
'Process User Selection and Create Icon If Requested
If iconyn = 6 Then
dtop = WshShl.SpecialFolders("Desktop")
set scut = WshShl.CreateShortcut(dtop & "\Assignment6.lnk")
scut.TargetPath = "c:\assignment6.vbs"
scut.IconLocation = "c:\disk.ico"
'Get user input for Drive letter selection
dltr = InputBox("Please enter a drive letter")
'Check for existance of drive and if it is ready
Set fso = WScript.CreateObject("Scripting.filesystemobject")
If Not fso.DriveExists(dltr) Then
Wscript.Echo "That Drive does not Exist"
Set dready = fso.GetDrive(dltr)
If Not (dready.IsReady) Then
Wscript.Echo "That Drive Is Not Ready"
'Check root of selected drive for existance of sub folders
<b>set fold = fso.GetFolder(dltr)
set subf = fold.subfolders
If subf.count =0 Then
Wscript.echo "The Selected Drive Contains No Sub-Folders"
Wscript.Wcho "The Drive Contains Sub Folders!"</b>