Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript root folder property question

Reply
 
Old 04-20-2009   #1 (permalink)
Vgolfmaster


 
 

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
Old 04-20-2009   #2 (permalink)
Vgolfmaster


 
 

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

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

Thread Tools


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
I can't share the root c folder Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46