Hi Folks
I have a VBS script which I need to run on a monthly basis which captures file information suhc as file Name, Type, Date Modified and more. When I processes each file it saves it all onto a CSV file so that I can process it on Excel.
To run the script I setup a batch file .bat
The issue is I need a GUI interface of some sort so that when the batch or vbs file is run it will ask the user to enter a drive letter to scan.
This is the code I have:
test.vbs:
Option Explicit
Dim objFS, objFld
Dim objArgs
Dim strFolder, strDestFile, blnRecursiveSearch
Dim strLines()
Dim i
Dim strCsv
i = 0
' 'Get the commandline parameters
' Set objArgs = WScript.Arguments
' strFolder = objArgs(0)
' strDestFile = objArgs(1)
' blnRecursiveSearch = objArgs(2)
'###################################
'MAKE SURE THESE VALUES ARE CORRECT
'###################################
strFolder = "C:\"
strDestFile = "C:\test\Output.csv"
blnRecursiveSearch = True
'Create the FileSystemObject
Set objFS=CreateObject("Scripting.FileSystemObject")
'Get the directory you are working in
Set objFld = objFS.GetFolder(strFolder)
'Now get the file details
GetFileDetails objFld, blnRecursiveSearch
'Write the csv file
Set strCsv = objFS.CreateTextFile(strDestFile, True)
strCsv.Write Join(strLines, vbCrLf)
'Close and cleanup objects
strCsv.Close
Set strCsv = Nothing
Set objFld = Nothing
Set strFolder = Nothing
Set objArgs = Nothing
Private Sub GetFileDetails(fold, blnRecursive)
Dim fld, fil
dim strLine(5)
If blnRecursive Then
'Work through all the folders and subfolders
For Each fld In fold.SubFolders
GetFileDetails fld, True
Next
End If
'Now work on the files
For Each fil in fold.Files
strLine(0) = fil.Path
strLine(1) = fil.Type
strLine(2) = fil.Size
strLine(3) = fil.DateCreated
strLine(4) = fil.DateLastModified
strLine(5) = fil.DateLastAccessed
Redim Preserve strLines(i)
strLines(i) = Join(strLine, ",")
i = i + 1
Next
end sub
And the run.bat
cscript.exe C:\script\test.vbs
As you can see test.vbs specifies what section to scan and capture. code: strFolder = "C:\"
What would be your best recommendation, the people running this are alot more less experienced then me with VB, so they will need some sort of GUI interface that will ask for a drive letter input and then modify line code strFolder = "C:\"
to whatever drive letter they entered and then run test.vbs.
Any help is appreciated.
:) Cheers