Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. However as Session IDs change this isn't something that I can use reliably. Is there any way to do the following:

  • Have a permanent session ID for a specific user
  • Find the session ID for a specific user
  • Other ways to start the GUI in my session on the server

Any help would be appreciated.

like image 277
tylerauerbeck Avatar asked Nov 27 '25 16:11

tylerauerbeck


1 Answers

I used to implement something like this when needed to launch gui tests on remote machine.

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.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.

You may create .bat file which would return session number with the following code:

@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>
like image 121
paulitto Avatar answered Nov 30 '25 05:11

paulitto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!