1
我试图在C#应用程序内执行此命令(列出Firefox扩展)。在C#上执行PowerShell命令行
Get-ChildItem -Path $env:USERPROFILE"\AppData\Roaming\Mozilla\Firefox\Profiles\*\extensions.json" | Get-Content
从MSDN文档,我想通了,应该看起来像是代码类似
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-ChildItem");
ps.AddParameter("Path", "\"$env:USERPROFILE\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\*\\extensions.json\"");
ps.AddCommand("Get-Content");
Collection<PSObject> results = ps.Invoke();
然而,“结果”是null
(当PS线不是)。我发现了一些类似的问题,但我真的没有办法用它来回答这个问题。任何人都知道我该如何修复我的代码?