How to escape command line arguments on PowerShell?

前端 未结 2 407
轻奢々
轻奢々 2020-12-30 10:17

It appears that I can escape command line arguments using single or double quotes:

PS C:\\> echo Hello World
Hello
World
PS C:\\> echo \'Hello World\'
         


        
相关标签:
2条回答
  • 2020-12-30 10:56

    Try putting an ampersand before the command. For example

    & 'C:\Program Files\winscp\winscp.exe'
    
    0 讨论(0)
  • 2020-12-30 11:07

    Use this:

    . "c:\program files\test.exe"
    

    Actually an even better solution would be:

    Invoke-Item "c:\program files\test.exe"
    

    or using the alias:

    ii "c:\program files\test.exe"
    

    Using Invoke-Item means that the proper Windows file handler would be used. So for an EXE file it would run it. For a .doc file for instance, it would open it in Microsoft Word.

    Here is one of the handiest PowerShell command lines around. Give it a try:

    ii .
    
    0 讨论(0)
提交回复
热议问题