RE: VBScript root folder property question
- From: Vgolfmaster <Vgolfmaster@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Apr 2009 09:20:01 -0700
Please disregard this mssg, I just realized I had to designate the root as
'drive letter + :' and not 'drive letter + :\'
That got it working!
___________________________________________________________________
"Vgolfmaster" wrote:
Hi again,.
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:
Option Explicit
'Declare Variables
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"
scut.Save
End if
'Get user input for Drive letter selection
'31
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"
Wscript.Quit
End If
Set dready = fso.GetDrive(dltr)
If Not (dready.IsReady) Then
Wscript.Echo "That Drive Is Not Ready"
Wscript.Quit
End If
'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.Quit
End If
Wscript.Wcho "The Drive Contains Sub Folders!"</b>
- References:
- VBScript root folder property question
- From: Vgolfmaster
- VBScript root folder property question
- Prev by Date: Re: VBScript halts with out error message
- Next by Date: Re: VBScript halts with out error message
- Previous by thread: VBScript root folder property question
- Next by thread: Script Mapping all Drives
- Index(es):
Relevant Pages
|