在上下文中启动远程进程
我想知道如何在用户上下文中远程启动进程,就像他启动它一样。让我解释一下。我知道如何远程启动进程,例如我想启动记事本:
Invoke-WmiMethod win32_process -name create -ComputerName $remoteMachine -ArgumentList "notepad" -credential (Get-Credential)
问题是它在“后台”启动记事本(而不是在用户上下文中),所以在这种情况下他不会看到打开的“记事本”对话框/进程(他将在任务管理器的进程列表中看到记事本)。我希望他看到记事本窗口对话框。
有人知道如何实现这一目标吗?
I am wondering how to start process remotely within the users context like he started it. Let me explain. I know how to start process remotely, so for example I want to start notepad:
Invoke-WmiMethod win32_process -name create -ComputerName $remoteMachine -ArgumentList "notepad" -credential (Get-Credential)
the problem is that it starts notepad "in the backround" (not in the users context), so in this case he won't see opened "notepad" dialog/process (he will see notepad just in the list of processes in task manager). I want him to see notepad window dialog.
Does anybody know how to achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用内置 SchTasks.exe 作为在远程系统上创建进程的受支持方法。它与内置任务计划程序服务交互,不需要 PsExec.exe。
要在远程计算机上创建任务(在此示例中以 SYSTEM 身份运行):
注意:
/SC ONCE /SD "01/01/1980" /ST "00:00:00"
这将具有相同的效果。/RU "DOMAIN\USER"
。如果用户已登录,则无需密码(/RP
选项)即可运行。
/Query /S COMPUTERNAME /TN "RemoteProcess" /V
查找当前状态,例如等待退出,然后读取退出代码。您还可以使用任务计划程序脚本对象通过脚本执行上述所有操作:
Use built-in SchTasks.exe for a supported way to create processes on a remote system. This interfaces with the built-in Task Scheduler service and does not require PsExec.exe.
To create a task on a remote machine (in this example running as SYSTEM):
Notes:
/SC ONCE /SD "01/01/1980" /ST "00:00:00"
which would have the same effect./RU "DOMAIN\USER"
. This will work without a password (/RP
option) if the user is logged in.
/Query /S COMPUTERNAME /TN "RemoteProcess" /V
to find the current status e.g. to wait for exit and then read the exit code.You can also do all the above with script using the Task Scheduler Scripting Objects:
您无法使用 WMI 或 PowerSHell 远程处理启动交互式进程。这是一个安全限制/功能。如果要启动远程交互进程,则需要使用 PSExec。
You cannot start interactive processes using WMI or PowerSHell remoting. This is a security limitation/feature. You need to use PSExec if you want to start remote interactive processes.