我在访问ps1文件的时候,一定要注意访问路径中是否包含空格。

包含空格要用单引号''来处理。

 

PowerShell -command Set-ExecutionPolicy "Bypass"
set filepath= '%CD%\AppDeployment.ps1'
PowerShell -command "& %filepath%"
Pause

 

 

 

错误的写法:

PS C:\> C:\Documents and Settings\Mingle\My Documents\PS\test.ps1

The term 'C:\Documents' is not recognized as a cmdlet, function, operable progr
am, or script file. Verify the term and try again.
At line:1 char:13
+ C:\Documents  <<<< and Settings\Mingle\My Documents\PS\test.ps1

 

正确的写法:

powershell.exe -noexit & 'C:\Documents and Settings\Mingle\My Documents\PS\test.ps1'

相关文章:

  • 2021-11-02
  • 2022-01-02
  • 2022-01-31
  • 2021-10-08
  • 2021-12-16
  • 2022-01-12
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2021-07-02
  • 2021-12-16
相关资源
相似解决方案