villasv
villasv

Reputation: 6831

Open and run commands on cmd from PowerShell

A similar question was asked several times on SO, and usually the answer is one of:

and a few other things that I've already tried. But my problem is: I have a specific program (cntkpy34.bat) that refuses to run on PowerShell. That is, with any of solutions like above I still get "Please execute this script from inside a regular Windows command prompt."

So what I really want is to invoke a new cmd.exe window and run the commands on it. How can this be achieved in a PowerShell script?

EDIT: inspecting the batch-file, this is how it verifies the shell:

if /I "%CMDCMDLINE%" neq ""%COMSPEC%" " (
    echo.
    echo Please execute this script from inside a regular Windows command prompt.
    echo.
    exit /b 0
)

Even starting a new cmd.exe process won't do it.

Upvotes: 6

Views: 31323

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

Start-Process cmd -Argument "/c cntkpy34.bat" -RedirectStandardOutput somefile

This will open a new cmd window and run that there

Upvotes: 11

Related Questions