VBScript root folder property question


  1.    20 Apr 2009 #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.    20 Apr 2009 #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?
Can someone guide me here: I am writing a vbscript file to retrieve properties of mails in mailbox. I want to know what key is used to get the...
VB Script
Question on USB root hub
Hi everybody, not a problem but a question: If I open device manager > USB Bus Controlers >>> select one particular USB Root Hub entry, >>>...
Vista General
Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'
I have a VBscript that uses the "WScript.Sleep 10000" command to pause briefly. When I run the VBscript interactively from a command-line,...
VB Script
I can't share the root c folder
I have a simple network with vista and xp. I share the c drive on the vista folder. I can map the vista c drive on the XP machine, however when I...
Vista networking & sharing
ISS Saving to root folder
When I try and save an asp file to the rootfolder it says i dont have permission. I have made sure the IIS folder is checked in the control...
Vista installation & setup
Root Folder Type
Any idea on what to do when vista it sets your C: drive root folder to be a music folder type? Usually you can view the properties of a folder and...
Vista General
syntax question with attached property
In XAML I could write: <Button DockPanel.Dock="Top" Content="OK" /> or <Button DockPanel.Dock="Top" /> <Button.Content> OK...
Avalon

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 07:14.
    .