简体   繁体   English

在远程服务器上启动GUI应用程序

[英]Start GUI application on remote server

I've looked through the forums and havn't found anything that quite helps me complete what I want to do. 我已经浏览了论坛,并没有找到任何可以帮助我完成我想做的事情。 What I'm looking for is a way to start a the GUI for an application on a remote server. 我正在寻找的是一种为远程服务器上的应用程序启动GUI的方法。 I've seen that I can do this with PsExec as long as I know what the session ID for my specific remote session is. 我已经看到我可以使用PsExec执行此操作,只要我知道特定远程会话的会话ID是什么。 However as Session IDs change this isn't something that I can use reliably. 但是,随着会话ID的改变,这不是我可以可靠使用的东西。 Is there any way to do the following: 有没有办法做到以下几点:

  • Have a permanent session ID for a specific user 拥有特定用户的永久会话ID
  • Find the session ID for a specific user 查找特定用户的会话ID
  • Other ways to start the GUI in my session on the server 在我的服务器上的会话中启动GUI的其他方法

Any help would be appreciated. 任何帮助,将不胜感激。

I used to implement something like this when needed to launch gui tests on remote machine. 我曾经在需要在远程机器上启动gui测试时实现这样的东西。

You can use -i parameter of psexec, which would run command 'interactively' in the specified session, for a specific user, it looks like this: 您可以使用psexec的-i参数,该参数将在指定的会话中以“交互方式”运行命令,对于特定用户,它看起来像这样:

psexec.exe \\<MachineName> -u <Username> -p <Password> -i <SessionNumber>

To get sessionNumber you can also use same psexec utility, you can execute "query session" with it on the remote machine for the specified user. 要获取sessionNumber,您还可以使用相同的psexec实用程序,您可以在远程计算机上为指定用户执行“查询会话”。

You may create .bat file which would return session number with the following code: 您可以使用以下代码创建将返回会话号的.bat文件:

@echo off
setlocal enabledelayedexpansion

set username=%2
set password=%3
set machine=%1

psexec.exe \\%machine% -u %username% -p %password% query session %username%>sessid.txt

set /a counter=0
for /F "tokens=* skip=1" %%a in (sessid.txt) do (
for %%b in (%%a) do (
set /a counter+=1
if !counter! == 3 (
    echo !counter!:%%b
    exit %%b
)
)
)

This batch file works well for me, you can use it like this 这个批处理文件适合我,你可以像这样使用它

getSessionNumber.bat <ServerName> <User> <Password>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM