Spaces cause split in path with PowerShell

前端 未结 12 877
广开言路
广开言路 2020-12-02 15:24

I\'m having an issue with powershell when invoking an exe at a path containing spaces.

PS C:\\Windows Services> invoke-expression \"C:\\Windows Services\\My

12条回答
  •  感情败类
    2020-12-02 15:57

    Would this do what you want?:

    & "C:\Windows Services\MyService.exe"
    

    Use &, the call operator, to invoke commands whose names or paths are stored in quoted strings and/or are referenced via variables, as in the accepted answer. Invoke-Expression is not only the wrong tool to use in this particular case, it should generally be avoided.

提交回复
热议问题