Powershell 在启动进程MSIEXEC中扩展$Env:TEMP时出现问题
我无法理解为什么以下命令不会触发Power Bi的静默安装-Powershell 在启动进程MSIEXEC中扩展$Env:TEMP时出现问题,powershell,Powershell,我无法理解为什么以下命令不会触发Power Bi的静默安装- Start-Process msiexec -wait -ArgumentList '/i $ENV:Temp\PBIDesktop_x64.msi /qn /norestart ACCEPT_EULA=1' 凡以下工程— Start-Process msiexec -wait -ArgumentList '/i C:\Users\ADMINI~1\AppData\Local\Temp\PBIDesktop_x64.msi /qn
Start-Process msiexec -wait -ArgumentList '/i $ENV:Temp\PBIDesktop_x64.msi /qn /norestart ACCEPT_EULA=1'
凡以下工程—
Start-Process msiexec -wait -ArgumentList '/i C:\Users\ADMINI~1\AppData\Local\Temp\PBIDesktop_x64.msi /qn /norestart ACCEPT_EULA=1
"
我正在使用提升的ISE,但第一个命令不会生成错误,也不会执行任何操作。我认为$ENV:TEMP
没有扩展。请帮忙
问候,,
如果使用单引号而不是双引号,PrateekPowershell将不会扩展字符串中的任何内容。因此,请将代码更改为:
Start-Process msiexec -wait -ArgumentList "/i $ENV:Temp\PBIDesktop_x64.msi /qn /norestart ACCEPT_EULA=1"
这说明了报价规则
简言之:
> $i = 1
> "Double quotes: $i + $i"
Double quotes: 1 + 1
> 'Single quotes: $i + $i'
Single quotes: $i + $i
如果您使用单引号而不是双引号,希望这有助于Powershell不会扩展字符串中的任何内容。因此,请将代码更改为:
Start-Process msiexec -wait -ArgumentList "/i $ENV:Temp\PBIDesktop_x64.msi /qn /norestart ACCEPT_EULA=1"
这说明了报价规则
简言之:
> $i = 1
> "Double quotes: $i + $i"
Double quotes: 1 + 1
> 'Single quotes: $i + $i'
Single quotes: $i + $i
希望这有帮助谢谢你的回答。谢谢你的回答。