0

assume that if i have value at cell C9, sheet1 down here is the code that i use for run .bat script from VBA

> Blockquote

Fileset = Sheet1.Range("C9")

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 & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "exit " & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "exit " & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:03")
SendKeys "exit " & "{ENTER}", True


> Blockquote

and this is res.bat that i will use

Blockquote

@echo off
>summary.txt (
  for %%F in (*chkpackage.log) do findstr /l ###FileSet### "%%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
)

Blockquote

my question is how do i going to put that value from c9 into ### Fileset ### in the bat file

thank you for your time and answer

1 Answer 1

1

You could use a parameter in the batch file to easily send the value of range "C9".

VBA code adding the parameter

SendKeys "start " & FilePath & " " & FileSet & "{ENTER}", True

Batch with with parameter

@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
)

EDIT: If the value of C9 has any blank spaces you'll need to add quotations around the parameter or it will only take the first word (Hopefully someone could suggest a much better way though!)

Sign up to request clarification or add additional context in comments.

2 Comments

can u explain a little bit more i want to know that "%1" what does it stand for (i'm new to coding sorry)
"%1" is the first command line paramater 'sent' to the batch file. Read more here about batch file paramaters: robvanderwoude.com/parameters.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.