Executing Batch File Using PowerShell

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Dilip Dodiya Dilip Dodiya 1 year, 8 months ago.

  • Author
    Posts
  • #23609
    Profile photo of Dilip Dodiya
    Dilip Dodiya
    Participant

    Hi There- Need help to execute cmd file (batch file) from PowerShell script. Please let me know if anyone did this. Thank You, Dilip

  • #23611
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    You can execute .cmd or .bat files the same way you execute any other external program. For example:

    c:\script.cmd Arg1 "Arg 2"
    
  • #23614
    Profile photo of Dilip Dodiya
    Dilip Dodiya
    Participant

    Thank you Dave. Just now I tried below and it worked.

    [b][i]Start-Process -FilePath "C:\PSDemo\CopyFile.bat" "C:\Source" "C:\Destination" -WindowStyle Hidden[/i][/b]

You must be logged in to reply to this topic.