Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 644035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:20:50+00:00 2026-05-13T21:20:50+00:00

I have a VBS script which I need to run on a monthly basis

  • 0

I have a VBS script which I need to run on a monthly basis which captures file information such 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 a lot 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.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:20:50+00:00Added an answer on May 13, 2026 at 9:20 pm

    It would be easiest just to add the drive letter as a parameter of your vbscript.

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

    Then you can just run the script like you were with the drive letter appended.

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

    You can then wrap the script in VB GUI (input box as suggested before) if the users really need it. Or better yet your script could just ask them to type in the drive letter.

    Side note (depending on which version of windows you are using and how you need the dates), the dir command will print a specific file date using the /t switch. So dir /ta would print the last accessed date. Unfortunately it only does one (accessed, modified, created) at a time. You might be able to use that and pipe it to a file (dir /ta > Output.txt) instead of writing a separate script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vb script (say myScript.vbs) which is used to monitor a file
I have a VBS script that is to copy a file from an old
I have a VB script which I want to run with python27, when I
I have the following .VBS script, which works, but it only returns the top
I have created a VBScript which pulls the service tag, username, and computer name
I have a vbscript file that I want to run in my vb.net application.
I have a little problem with a simple vbScript. The script has to run
I have a batch file running which spits out a text/html file. The batch
I am trying to run a VB script which is based on a 32-bit
Say I have a batch file where in I call a VBScript(which returns the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.