Ok, Im writing a user database for my companys intranet.
The database uses an sql file to store user details. These details are displayed in a data grid.
At the end of the datagrid, there is a button that allows the administrator to vnc onto a users computer.
Now when i run the application through visual studio, it works fine.
When the application is run through iis, over the intranet though. nothing happens when the button is clicked.
I think it may be due to my inappropriate use of the shell command. any ideas??
The database uses an sql file to store user details. These details are displayed in a data grid.
At the end of the datagrid, there is a button that allows the administrator to vnc onto a users computer.
Now when i run the application through visual studio, it works fine.
When the application is run through iis, over the intranet though. nothing happens when the button is clicked.
Code:
Protected Sub usergrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles usergrid.RowCommand
If multiple ButtonField column fields are used, use the
CommandName property to determine which button was clicked.
If Not Session("doneonce") Then stops the code running twice
If e.CommandName = "vncuser" Then if the button is pressed
Convert the row index stored in the CommandArgument
property to an Integer.
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Get the last name of the selected author from the appropriate
cell in the GridView control.
Dim selectedRow As GridViewRow = usergrid.Rows(index)
Dim contactCell As TableCell = selectedRow.Cells(6)
Dim contact As String = contactCell.Text
If Session("superuser") = True Then
vnc_connect(contact)
Else
authtxt.Text = "<font color=red>You are not authorised to use VNC</font>"
End If
Display the selected author.
Message.Text = "You selected " & contact & "."
End If
End If
If Session("doneonce") = True Then
Session("doneonce") = False
Else
Session("doneonce") = True
End If
End Sub
Private Sub vnc_connect(ByVal ip As String)
Dim vncfile As String
vnc file contents
vncfile = "[Connection]" & vbCrLf & "Host=" & ip & vbCrLf & "Password=password" & vbCrLf & "[Options]" & vbCrLf & "UseLocalCursor=1" & vbCrLf & "UseDesktopResize=1" & vbCrLf & "FullScreen=0" & vbCrLf & "FullColour=1" & vbCrLf & "LowColourLevel=1" & vbCrLf & "PreferredEncoding=hextile" & vbCrLf & "AutoSelect=1" & vbCrLf & "Shared=0" & vbCrLf & "SendPtrEvents=1" & vbCrLf & "SendKeyEvents=1" & vbCrLf & "SendCutText=1" & vbCrLf & "AcceptCutText=1" & vbCrLf & "DisableWinKeys=1" & vbCrLf & "Emulate3=0" & vbCrLf & "PointerEventInterval=0" & vbCrLf & "Monitor=\\.\DISPLAY1" & vbCrLf & "MenuKey=F8" & vbCrLf & "AutoReconnect=1"
Try
Kill("C:\Program Files\RealVNC\VNC4\user.vnc") delete old vnc file
Catch ex As Exception
End Try
create new vnc file
My.Computer.FileSystem.WriteAllText("C:\Program Files\RealVNC\VNC4\user.vnc", vncfile, False, Encoding.ASCII) must be ascii encoded otherwise hidden characters are inserted at the begining of the file
run vnc with vnc file
Shell(ChrW(34) & "C:\Program Files\RealVNC\VNC4\vncviewer.exe " & ChrW(34) & "-config " & ChrW(34) & "c:\program files\realvnc\vnc4\user.vnc", AppWinStyle.NormalFocus, False, -1) & ChrW(34) & is ascii code for quote. must be added for command line to work
End Sub
I think it may be due to my inappropriate use of the shell command. any ideas??