windows - 使用 PowerShell Direct 时,通过 psexec 打开的窗口为空白,但当 psexec 本地启动时,窗口正常

标签 windows powershell hyper-v psexec

我正在尝试构建一个简单的环境来自动截图。我有多个 Hyper-V 虚拟机,我需要使用 PowerShell Direct 以特殊顺序在它们上运行命令。当我运行 psexec 通过 PowerShell Direct 打开 notepad.exe 时,记事本的窗口打开,但它是空白的。我可以盲目地单击窗口上的控件(例如工具栏上的控件),看起来它们可以工作,但除了空白窗口之外实际上什么也没有显示。

我现在看到的在现有 session 中打开 Windows 的唯一简单选项是运行 psexec (任何其他建议将不胜感激,因为我尝试坚持仅使用 PowerShell 的方法遇到了障碍,请参阅Starting a GUI application on a guest VM with PowerShell Direct)。

我在其中一台虚拟机上运行 psexec,以在 session 2 中启动 notepad.exe。此 PowerShell 代码段在主机虚拟机上运行,​​它通过 PowerShell 与 guest 虚拟机联系直接。

Invoke-Command  -VMName 'client1.example.com' -Credential $credential -ScriptBlock {
C:\bin\psexec.exe \\client1.example.com -i 2 "notepad.exe"
}

notepad.exe 启动,但窗口为空白。这是 psexec 中的错误吗?

请看截图:

enter image description here

当我直接在 guest 虚拟机中运行 psexec 时,不会出现此问题。

C:\bin\psexec.exe \\client1.example.com -i 2 "notepad.exe"

enter image description here

最佳答案

通过添加-s选项解决。我不明白为什么会出现这个问题,也不明白“在系统帐户中”运行它有何帮助。

-s Run the remote process in the System account.

顺便说一句,当我启动 explorer.exe 时,问题不会发生。

关于windows - 使用 PowerShell Direct 时,通过 psexec 打开的窗口为空白,但当 psexec 本地启动时,窗口正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62478070/

相关文章:

linux - 测试厨房卡在 "creating virtual machine"

c++ - Win32 : Passing lParam to CreateWindow and keeping track of open windows

windows - SetConsoleActiveScreenBuffer 使 ReadConsole 返回 ERROR_SHARING_VIOLATION

windows - Inno Setup - 检查目标中是否存在文件,否则不中止安装

c++ - GlBufferDataARB 给我内存问题

windows-phone - 如何运行Windows Phone 10模拟器?

windows - 如何在没有 Hyper-V 支持的 Windows 10 家庭版上安装 Vagrant?

用于更改 csproj 文件中的值的 Powershell 脚本

powershell - 我可以在 PowerShell 'string' 中使用单引号吗?

string - 递归查找文件中的文本 (PowerShell)