我測驗新的powershell/batch下載并安裝字體oneliner,但到目前為止沒有運氣(每次在cmd中出錯,在PS下都可以)......我相信某處的引號有問題
要點是可以從批處理中運行的簡單 oneliner
POWERSHELL -NoProfile -ExecutionPolicy Bypass -Command "& {$fonts=@('Roboto','Ubuntu') | ForEach-Object {(New-Object System.Net.WebClient).DownloadFile('https://fonts.google.com/download?family=$_', '$env:TEMP\$_.zip'); Expand-Archive -Force '$env:TEMP\$_.zip' -DestinationPath '$env:TEMP\FONTS'}}"
謝謝
uj5u.com熱心網友回復:
由于您在命令中使用單引號,Powershell 的變數替換機制將不起作用。所以你必須使用雙引號用反斜杠掩蓋它們。這對我有用:
POWERSHELL -NoProfile -ExecutionPolicy Bypass -Command "& {$fonts=@('Roboto','Ubuntu') | ForEach-Object {(New-Object System.Net.WebClient).DownloadFile(\"https://fonts.google.com/download?family=$_\", \"$env:TEMP\$_.zip\"); Expand-Archive -Force \"$env:TEMP\$_.zip\" -DestinationPath \"$env:TEMP\FONTS\"}}"
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/478117.html
