Solved

vncviewer.exe in vb app

Posted on 2004-08-31
9
692 Views
Last Modified: 2008-02-01
Hi I have vnc running in all computers in my network. I have a managing application that I created and I just want to know if it's possible to implement vnviewer to it. I just want a simple example of how can I call on the viewer with a specific computer name and password. If possible also to be able change some of the settings like full screen. Please tell me this is possible.
0
Comment
Question by:DARKSAGES
  • 6
  • 3
9 Comments
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11945895
There are some command line switches to the viewer but you can also save the connection information as a .vnc file.  If you looked at the format of the .vnc file it would be possible to dynamically create the file and then just shell to vnc passing it the path to the .vnc file.
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947124
Other options include:
/8bit
/shared
/noshared
/swapmouse
/belldeiconify
/listen
/fullscreen
/viewonly
/emulate3
/scale a/b
/config configfile  <-- This was the one I was talking about
/encoding encname
/compresslevel n
/quality n
/nocursorshape
/noremotecursor
 server[:display]
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947287
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long


Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = &HFFFF      '  Infinite timeout

Const PathToVNCViewer = "C:\<<Path Too>>\tightvnc-1.2.2_x86_viewer\vncviewer.exe"
Public Sub Connect(szMachine As String)
  Call ShellAndWait(PathToVNCViewer & " /8bit /shared /viewonly " & szMachine, vbNormalFocus)
End Sub

' Start the indicated program and wait for it
' to finish, hiding while we wait.
Private Sub ShellAndWait(ByVal program_name As String, _
    ByVal window_style As VbAppWinStyle)
Dim process_id As Long
Dim process_handle As Long

    ' Start the program.
    On Error GoTo ShellError
    process_id = Shell(program_name, window_style)
    On Error GoTo 0

    ' Hide.
    Me.Visible = False
    DoEvents

    ' Wait for the program to finish.
    ' Get the process handle.
    process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
    If process_handle <> 0 Then
        WaitForSingleObject process_handle, INFINITE
        CloseHandle process_handle
    End If

    ' Reappear.
    Me.Visible = True
    Exit Sub

ShellError:
    MsgBox "Error starting task " & _
        program_name & vbCrLf & _
        Err.Description, vbOKOnly Or vbExclamation, _
        "Error"
End Sub
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947324
The only way to get the password is to have it in a .vnc file or to modify the code for the viewer itself.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DARKSAGES
ID: 11948108
where is the .vnc file located i dont see one?
0
 
LVL 7

Accepted Solution

by:
jacobhoover earned 500 total points
ID: 11948143
Open up a viewer instance then right click on the menu, once connected, and click save connection info as...

It will create a text file similar to:
[connection]
host=<machine name here>
port=5900
password=<encoded password here>
[options]
use_encoding_0=1
use_encoding_1=1
use_encoding_2=1
use_encoding_3=0
use_encoding_4=1
use_encoding_5=1
use_encoding_6=1
use_encoding_7=1
use_encoding_8=1
preferred_encoding=7
restricted=0
viewonly=1
fullscreen=0
8bit=1
shared=1
swapmouse=0
belldeiconify=0
emulate3=1
emulate3timeout=100
emulate3fuzz=4
disableclipboard=0
localcursor=1
scale_den=1
scale_num=1
cursorshape=1
noremotecursor=0

So the obvious question is do you use static passwords or do they vary from machine to machine?  If they change you will have to find a means of encoding the pass into the correct format if you want to connect without having to enter it.

0
 

Author Comment

by:DARKSAGES
ID: 11948151
no the password is the same one for all machines
0
 

Author Comment

by:DARKSAGES
ID: 11948172
thanx
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11948175
Also,
  the switches I listed are for TightVNC... Version 1.2.2.. There are numerious flavors of VNC available so there may be different switches available in the newer versions.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SUM 2 INTEGER ARRAYS INTO 1 10 93
Turning python script into an applet 12 104
Path to Python 9 107
Programatically extract date from website 8 67
This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now