VB GUI interface to run VBS Script

I have a VBS script that I need to run on a monthly basis that captures suhc file information like file name, type, date and more. When I process each file, it saves everything in a CSV file so that I can process it in Excel.

To run the script, I install the .bat batch file

The problem is that I need some kind of GUI interface so that when I run the batch file or vbs, he asks the user to enter the drive letter for scanning.

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 run.bat

cscript.exe C:\script\test.vbs

As you can see, test.vbs indicates which section to scan and capture. the code:strFolder = "C:\"

, , , , VB, - GUI, , strFolder = "C:\" , , test.vbs.

.

:)

+3
5

vbscript.

Set oArgs = WScript.Arguments
DriveLetter = oArgs(0)
strFolder = DriveLetter & ":\"

script , .

cscript.exe C:\script\test.vbs C

script VB GUI ( , ), . , script .

( , ), dir /t. , dir /ta . , (, , ) . , (dir /ta > Output.txt) script.

+3

InputBox - , , , .

BrowseForFolder, . , , , , .

http://msdn.microsoft.com/en-us/library/bb774065(VS.85).aspx

+2

vb.net?

.

Dim driveLetter as String = combobox.text

If (Directory.Exists(driveLetter)) Then
 strFolder = combobox.text
Else
 msgbox("Drive letter does not exist")
End If
+2

Source: https://habr.com/ru/post/1733353/


All Articles