2

I have a PowerShell script which creates a development environment and part of the process is to call a batch file to get source code. The problem is the batch file calls another batch file which has a pause at the end of it. This means the PowerShell script will not move on to the next task.

I can't remove the pause from the batch file as it is maintained by a different team.

I have created another batch file which gets around the pause issue:

    @echo OFF

    @echo Calling test.cmd...
    @echo | call test.cmd
    @echo Done.

Is there a way in PowerShell to do this so I don't need my batch file?

PowerShell script

Invoke-Expression -command "d:\relay.cmd"

2 Answers 2

4

You can do it the same way in PowerShell. Pass something by the pipeline:

@()|.\test.cmd
Sign up to request clarification or add additional context in comments.

Comments

0

Answering to an old question because I had a similar problem.

You can use the echo and pass someting as the parameter. So, following also does the trick:

echo "" | .\test.cmd

3 Comments

Is that the case for powershell? I'm getting: echo/: The term 'echo/' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The question is about PowerShell so that should be taken.
Had you read the question? It's about running a batch file with PowerShell.

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.