How can I modify the commands in this batch file?

Here is a .bat file which contains the following commands:

@echo off
setlocal enabledelayedexpansion
set InputFile=C:\input.txt
set FoundDouble=FALSE
set /a TestIndex = -1
for /f "tokens=1* delims=:" %%a in ('type "%InputFile%" ^| findstr.exe /n /r /i /c:"^DTM"') do (
      echo Line %%a: %%b
      if !TestIndex!==%%a (
            set FoundDouble=TRUE
      ) else (
            set /a TestIndex = %%a + 1
      )
)
if %FoundDouble%==FALSE (
      cscript.exe /nologo "%~dp01.vbs"
) else (
      cscript.exe /nologo "%~dp02.vbs"
)


I would like to modify the script so that it will act as follows:

If the input file does not contain any lines which start with SAC, then I want to run a 3rd script which is a powershell script instead, otherwise I would like it to run it's normal course searching for the DTM.

Can this .bat file be modified in this way?
100questionsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Sure:
@echo off
setlocal enabledelayedexpansion
set InputFile=C:\Temp\input.txt
set PSScript=C:\Temp\test.ps1
set VBScript1=C:\Temp\test1.vbs
set VBScript2=C:\Temp\test2.vbs

findstr.exe /r /i /c:"^SAC" "%InputFile%" >NUL
if errorlevel 1 (
	powershell.exe -ExecutionPolicy Bypass -NoProfile -Command "& '%PSScript%'"
	goto :eof
)

set FoundDouble=FALSE
set /a TestIndex = -1
for /f "tokens=1* delims=:" %%a in ('type "%InputFile%" ^| findstr.exe /n /r /i /c:"^DTM"') do (
	echo Line %%a: %%b
	if !TestIndex!==%%a (
		set FoundDouble=TRUE
	) else (
		set /a TestIndex = %%a + 1
	)
)
if %FoundDouble%==FALSE (
	cscript.exe /nologo "%VBScript1%"
) else (
	cscript.exe /nologo "%VBScript2%"
)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
100questionsAuthor Commented:
Thanks I will try this and report back.
100questionsAuthor Commented:
Thanks works very good.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.