tylerauerbeck
tylerauerbeck

Reputation: 173

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:

Any help would be appreciated.

Upvotes: 3

Views: 1410

Answers (1)

paulitto
paulitto

Reputation: 4673

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>

Upvotes: 1

Related Questions