Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open and run commands on cmd from PowerShell

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

  • run the same command on PowerShell because it's also there
  • run cmd and then the commands
  • invoke cmd passing /c

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.

like image 918
villasv Avatar asked Nov 12 '16 13:11

villasv


1 Answers

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

This will open a new cmd window and run that there

like image 177
4c74356b41 Avatar answered Oct 17 '22 13:10

4c74356b41