Connect to VNC Viewer from Windows Service

Here you will find help for frequently asked questions as well as for your specific question.

Connect to VNC Viewer from Windows Service

Postby kb00 » 2017-09-15 11:29

Hi All,

I'd like to ask for your help, as I have been struggling with this issue for a while. Maybe someone can help me:

I have a vncviewer.exe started locally, listening on port 5900 (vncviewer.exe -listen 5900)
I would like to set up a connection to this viewer by initiating the connection from the UltraVNC Server. However, I'd like to do that by starting the connection from a Windows Service.

I started the server with this command (this works perfectly fine from my Windows Service as well. uvnc_service gets started, I can see its systray and everything):
Code: Select all
winvnc.exe -startservice


Then, I try to connect with this one:
Code: Select all
winvnc.exe -connect localhost::5900 -service


Problem is: The last command above works perfectly, if issued from cmd. It also works if I call this from a regular .NET application. But if the same application is installed as a service, nothing happens. My service is running as current user (same as cmd).

Could you tell me what could be the problem, maybe give me some hint where to look around? Or if my commands should work at all?

Many thanks,
kb00

Related .NET code:
Code: Select all
processServer = new Process();
processServer.StartInfo = new ProcessStartInfo
{
         FileName = "C:\\Users\\myUser\\Documents\\UltraVNC\\winvnc.exe",
         Arguments = "-autoreconnect - connect localhost::5900 - service"
};
processServer.Start();
kb00
 
Posts: 2
Joined: 2017-09-15 11:14

Re: Connect to VNC Viewer from Windows Service

Postby Rudi De Vos » 2017-09-15 22:32

vncviewer -listen

Default server listen to 5900 and viewer to 5500

1) Click try icon, add new connection
Hostname [pc running viewer]

You can use any port
viewer -listen 5505
Hostname [ip:5505]

2)
winvnc.exe -autoreconnect - connect viewer_ip::5505

If the commandline works add to the ultravnc.ini file
[admin]
service_commandline=-autoreconnect - connect viewer_ip:5505

Now you can start/stop the service and he autoconnect to the veiwer
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5485
Joined: 2004-04-23 10:21

Re: Connect to VNC Viewer from Windows Service

Postby kb00 » 2017-09-18 06:14

Hello,

thanks Rudi. Both of the methods you described working perfectly.

However, I was looking for a way to start sessions in an automated way from my Windows service using command line without having to modify the ultravnc.ini file (or using the GUI).

But if there are no other options, I'll just use the second method.

Thanks again,
kb00
kb00
 
Posts: 2
Joined: 2017-09-15 11:14

Re: Connect to VNC Viewer from Windows Service

Postby Rudi De Vos » 2017-09-18 18:24

Sorry, no other methods
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5485
Joined: 2004-04-23 10:21


Return to General help

Who is online

Users browsing this forum: Bing [Bot] and 4 guests