我知道如何使用psexec
以交互方式为单个会话运行程序:
PsExec.exe -s -i 7 \\computername notepad.exe
但我需要为所有登录用户运行它,而不仅仅是针对特定会话。
怎么做?
答案 0 :(得分:0)
您可以使用Qwinsta
命令列出所有活动会话(更多信息here):
qwinsta /SERVER:servername
以下是此命令的示例输出:
现在,您可以从列ID
获取所有RDP连接ID并运行命令:
PsExec.exe -s -i 0 \computername notepad.exe
PsExec.exe -s -i 1 \computername notepad.exe
PsExec.exe -s -i 17 \computername notepad.exe
PsExec.exe -s -i 19 \computername notepad.exe
PsExec.exe -s -i 32 \computername notepad.exe
PsExec.exe -s -i 39 \computername notepad.exe
PsExec.exe -s -i 40 \computername notepad.exe
PsExec.exe -s -i 55 \computername notepad.exe
PsExec.exe -s -i 69 \computername notepad.exe
PsExec.exe -s -i 70 \computername notepad.exe
如果您想自动完成此过程,您可以:
qwinsta
输出(请参阅示例here)PsExec
命令