Shell.Application 中的 powershell 字串內插

Shell.Application 中的 powershell 字串內插

我有一個 PowerShell 腳本;

$filex = Get-ChildItem C:\somewhere\anotherfolder\anotherfolder\lastfolder\ -recurse -Filter *coolfile.exe
$ShellExp = New-Object -ComObject Shell.Application
$ShellExp.open("{$filex} http://speedtest.tele2.net/10MB.zip %appdata%\101x.zip")

我該怎麼做才能執行 $filex ?

答案1

我相信你在問同樣的問題:https://stackoverflow.com/q/44035920/7537973 在這種情況下,答案就在這裡:https://stackoverflow.com/a/44036090/7537973

Tl;dr 將函數放在 $() 內部,因此在您的範例中它將是$ShellExp.open("$(Get-ChildItem C:\somewhere\anotherfolder\anotherfolder\lastfolder\ -recurse -Filter *coolfile.exe) http://speedtest.tele2.net/10MB.zip %appdata%\101x.zip")

相關內容