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

后端 未结 2 1984
不知归路
不知归路 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"
    

提交回复
热议问题