Windows Vista Forums

VBScript root folder property question

  1. #1


    Vgolfmaster Guest

    VBScript root folder property question

    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>



      My System SpecsSystem Spec

  2.   


  3. #2


    Vgolfmaster Guest

    RE: VBScript root folder property question

    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>
    >
    >

      My System SpecsSystem Spec


VBScript root folder property question
Similar Threads
Thread Forum
How to retireve "PR_SEARCH_KEY" property of a mail in vbscript formailbox using Outlook MAPI? VB Script
Question on USB root hub Vista General
Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep' VB Script
ISS Saving to root folder Vista installation & setup
syntax question with attached property Avalon