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

  • Home
  • SEARCH
  • 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 8982251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:32:07+00:00 2026-06-15T20:32:07+00:00

Here is batch file code: @echo off >summary.txt ( for %%F in (*chkpackage.log) do

  • 0

Here is batch file code:

@echo off >summary.txt (
    for %%F in (*chkpackage.log) do findstr /l %1 "%%F" nul||echo %%  F:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A)

and here is the code in VBA Excel calling the batch file:

FileSet = Sheet1.Range("C13")
txtFpath = Sheet1.Range("C7").Value
FilePath = txtFpath & "\res.bat"

ChDrive "D"
RSP = Shell(Environ$("COMSPEC"), vbNormalFocus)
Application.Wait Now + TimeValue("00:00:03")
SendKeys "CD " & txtFpath & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "start " & FilePath & " " & FileSet & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "exit " & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "exit " & "{ENTER}", True

But I don’t want to use a batch file. I want to change it into command to use on VBA.
So i can use only VBA and run command line instead of using VBA to call batch and command line.

Easy explanation is I want to put that command in batch file into Excel-VBA and run it by using VBA call cmd and auto input that command to cmd like that Sendkeys code.

  • 1 1 Answer
  • 0 Views
  • 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-06-15T20:32:08+00:00Added an answer on June 15, 2026 at 8:32 pm

    You can add a reference to the Microsoft Scripting Runtime (Tools -> References from the VBA IDE), which provides the FileSystemObject and allows you to do the following:

    Dim fso As New FileSystemObject
    Dim fle As Variant
    For Each fle In fso.GetFolder(txtFpath).Files
        'processing here
    Next
    

    You can limit the files to a particular pattern using the Like operator:

    For Each fle In fso.GetFolder(txtFpath).Files
        If fle.Name Like "*chkpackage.log" Then
            'processing here
        End If
    Next
    

    You can use the OpenAsTextStream method to get a TextStream object, and the ReadAll method to read the file contents:

    For Each fle In fso.GetFolder(txtFpath).Files
        If fle.Name Like "*chkpackage.log" Then
            Dim txt As TextStream, contents As String
            Set txt = fle.OpenAsTextStream(ForReading)
            contents = txt.ReadAll
            txt.Close
    
            'process contents of file here
        End If
    Next
    

    You can use Split(contents, vbCrLf) to split the contents into an array of lines before parsing (use vbLf or vbCr if the line delimiter is Unix/Mac and not Windows).

    Alternatively, you can use the ReadLine method to read the file line by line. You need to check the AtEndOfStream property to ensure that you’re not trying to read past the end of the file:

    'Within the For Each loop
    Dim txt As TextStream, currentLine As String
    Set txt = fle.OpenAsTextStream(ForReading)
    Do While Not txt.AtEndOfStream
        currentLine = txt.ReadLine
    
        'process current line here
    Loop
    txt.Close
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my batch script: @echo off cls set SOURCE=svn://vcrep/UXP/ercpac/trunk/ set SVN=C:\Program Files\TortoiseSVN\bin %SVN%\TortoiseProc.exe /command:update
I have a batch file here: StackOverflows code window doesn't show anything when I
here i need a batch file which can apply and create label or base
Here I have 2 requirements: Need a batch file to start a process on
As far as I can tell this is perfectly valid batch-file code, just a
Just wondering if there is any code in batch file that can find a
I have a batch file with this snippet in it: systeminfo|findstr /B Host Name:|findstr
here is the portion of code giving me trouble: IF EXIST TH_BUILD_* ( ECHO
I am on Windows 7 Enterprise and calling a jar from batch file which
I want my batch file to stay open after processing is complete. Here is

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.