'==========================================================================
'
' VBScript: BrowseFolderSUB.vbs
'Author: Kenneth Værsland
'Date 10/12/2008
' NAME: BrowseFolderSUB.vbs
'==========================================================================
subGetFolder
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem, objPath
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFOlder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End Sub
'==========================================================================
'Author: Kenneth Værsland
'Date 10/12/2008
' Name: BrowseFolderListFiles.vbs
'==========================================================================
Option Explicit
On Error Resume Next
Dim FolderPath 'Path to the folder to be searched for files
Dim objFSO 'The fileSystemObject
Dim objFolder 'The folder object
Dim colFiles 'Collection of files from files method
Dim objFile 'individual file object
Dim strOUT 'Single output variable
subCheckWscript 'Ensures script is running under wscript
subGetFolder 'Calls the browseForFOlder method
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strOUT = strOUT & objFile.Name & vbTab & objFile.Size _
& " bytes" & VbCrLf
Next
WScript.Echo strOUT
' ****** subs below ******
Sub subCheckWscript
If UCase(Right(WScript.FullName, 11)) = "CSCRIPT.EXE" Then
WScript.Echo "This script must be run under WScript."
WScript.Quit
End If
End Sub
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
FolderPath = objFolderItem.Path
End Sub
Friday, January 9, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment