zeocrash Posted February 28, 2007 Posted February 28, 2007 Ok, I'm writing a user database for my company's 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 user's 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. 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?? Quote
Administrators PlausiblyDamp Posted February 28, 2007 Administrators Posted February 28, 2007 The shell command will run the application on the IIS box itself (as whatever user the web-server is configured to run as). Rather than trying to launch the .vnc file on the server you could have it downloaded to the client and run from there - that should launch the vnc viewer on the destop. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
zeocrash Posted March 1, 2007 Author Posted March 1, 2007 so how would i go about loading the vnc file onto the client system and running vnc viewer client side?? Quote
Administrators PlausiblyDamp Posted March 4, 2007 Administrators Posted March 4, 2007 Something like 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" Response.Clear() Response.ClearHeaders() Response.ContentType = "application/text" Response.AppendHeader("Content-Disposition", "attachment; filename=Run.vnc") Dim b() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(vncfile) Response.BinaryWrite(b) Response.End() on the server side should generate the relevant content and send it down to the browsers as a .vnc file - as long as the client has the vnc viewer installed it should prompt them to open it with the correct app and that should be that. You may need to change the line Response.ContentType = "application/text" to Response.ContentType = "VncViewer/Config" though - I don't have vnc installed here so I couldn't test it for sure. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.