none
problem with a simple batch file RRS feed

  • Question

  • Hello

    in my test lab, I am creating a cmd batch file which first sets the system execution policy to bypass & then continues into command prompt & does some stuff there. so I need the following commands be run in turn:

    powershell set-executionpolicy bypass -force

    cmd

    @echo off

    echo the installation of the following App will take about 10 minutes

    cd c:\myfolder

    myApp.exe

    but only the first line of the command runs & it ends up in the following step:

    any help please !
    Thursday, January 15, 2015 9:36 AM

Answers

  • You cannot jsut run a list of commands.  You also cannot use PowerShell to execute BAT commands.  Start by learning how to create and run a classic BAT file or jsut skip BAT files and run PowerShell.

    powershell -command "Write-Host ' the installation of the following App will take about 10 minutes' -fore green; cd c:\myfolder;myApp.exe"

    Just past that at a prompt or place the whole line in a barch file.

    OR - skip Powershell altogether and run a batch file only.

    This would be you batch file:

    @echo off
    echo the installation of the following App will take about 10 minutes
    cd c:\myfolder
    myApp.exe


    ¯\_(ツ)_/¯

    • Proposed as answer by Mike Laughlin Thursday, January 15, 2015 2:15 PM
    • Marked as answer by maria.holme1 Friday, January 16, 2015 6:56 PM
    Thursday, January 15, 2015 11:57 AM

All replies

  • You cannot jsut run a list of commands.  You also cannot use PowerShell to execute BAT commands.  Start by learning how to create and run a classic BAT file or jsut skip BAT files and run PowerShell.

    powershell -command "Write-Host ' the installation of the following App will take about 10 minutes' -fore green; cd c:\myfolder;myApp.exe"

    Just past that at a prompt or place the whole line in a barch file.

    OR - skip Powershell altogether and run a batch file only.

    This would be you batch file:

    @echo off
    echo the installation of the following App will take about 10 minutes
    cd c:\myfolder
    myApp.exe


    ¯\_(ツ)_/¯

    • Proposed as answer by Mike Laughlin Thursday, January 15, 2015 2:15 PM
    • Marked as answer by maria.holme1 Friday, January 16, 2015 6:56 PM
    Thursday, January 15, 2015 11:57 AM
  • I strongly suggest studying the basics of Windows before tacklling PowerShell.  It will save you a lot of pain and confusion.

    ¯\_(ツ)_/¯

    Thursday, January 15, 2015 11:58 AM
  • worked. thanks ok
    Friday, January 16, 2015 6:56 PM