How can I execute an external program with parameters in PowerShell?

后端 未结 2 1976
不知归路
不知归路 2020-12-03 04:12

I have read this answer stackoverflow answer and it get\'s me there half way. Here is what I need to do.

Execute this command:

\"c:\\myexe.exe 

        
相关标签:
2条回答
  • 2020-12-03 04:26

    If you want to run a program, just type its name and parameters:

    notepad.exe C:\devmy\hi.txt
    

    If you want to run an exe and redirect stdin to it which your example seems to be an attempt of, use:

    Get-Content c:devmy\hi.txt | yourexe.exe 
    

    If you need to specify the full path to the program then you need to use ampersand and quotes otherwise powershell thinks you are defining a plain string:

    &"C:\Program Files (x86)\Notepad++\notepad++.exe"
    
    0 讨论(0)
  • 2020-12-03 04:52

    Simply use & operator

    & "Program\path\program.exe" "arg1" "arg2" ....
    
    0 讨论(0)
提交回复
热议问题