代码之家  ›  专栏  ›  技术社区  ›  Eric Schoonover thSoft

使用PowerShell远程处理在活动用户会话中启动程序

  •  2
  • Eric Schoonover thSoft  · 技术社区  · 15 年前

    是否可以检测到特定用户在计算机上有打开的会话,并在该会话中打开进程,以便用户使用PowerShell远程处理与应用程序进行交互?

    我将如何检测哪些用户在计算机上打开了会话,以及他们的状态(活动、空闲、断开连接等)?我如何在其中一个会话中启动应用程序?

    更新
    我发现您可以识别正在运行进程的会话ID:

    PS > ( Get-Process notepad ).SessionId
    1
    

    不过,在您启动进程时,我似乎找不到为它指定会话ID的方法。

    1 回复  |  直到 15 年前
        1
  •  2
  •   x0n    15 年前

    PowerShell无法执行此操作,但Microsoft(以前是SysInternal的)工具PSExec可以执行此操作。看看-i参数:

     -i         Run the program so that it interacts with the desktop of the
                specified session on the remote system. If no session is
                specified the process runs in the console session.
    
    推荐文章