Wednesday, December 15, 2010

VB.NET Capture Client Computer NAME

 Imports System.Net

Dim computer_name() As String
        computer_name = Split(System.Net.Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName, ".")
        Response.Write(computer_name(0).ToUpper)

OR

Dim strComputerName As String
        Dim host As System.Net.IPHostEntry
        host = System.Net.Dns.GetHostEntry(Request.ServerVariables.Item("REMOTE_HOST"))
        strComputerName = host.HostName
        Response.Write(strComputerName)

VB.NET Read from TEXT File

 Dim FILENAME As String = "c:\IP.txt"

        Dim objStreamReader As StreamReader
        objStreamReader = File.OpenText(FILENAME)
        Dim contents As String = objStreamReader.ReadToEnd()
        Button1.Text = contents
        objStreamReader.Close()

VB.NET Insert into TEXT File

Imports System.IO

Dim FILENAME As String = Server.MapPath("IP.txt")
                          OR
Dim FILENAME As String = "c:\IP.txt"

            Dim objStreamWriter As StreamWriter
            objStreamWriter = File.AppendText(FILENAME)
            objStreamWriter.WriteLine("External ip :" & externalip)
            objStreamWriter.WriteLine("Local ip    :" & localipaddresses)
            objStreamWriter.WriteLine("Remote ip   :" & strip)
            objStreamWriter.WriteLine("DateTime    :" & DateTime.Now)
            objStreamWriter.WriteLine("----------------------------------")
            objStreamWriter.Close()
            Dim objStreamReader As StreamReader
            objStreamReader = File.OpenText(FILENAME)
            Dim contents As String = objStreamReader.ReadToEnd()
            objStreamReader.Close()

Monday, December 13, 2010

VB.NET Getting Local ip of Client

Dim hostname As String

        hostname = System.Net.Dns.GetHostName()
        Dim localipaddresses As New IPHostEntry
        localipaddresses = Dns.GetHostEntry(hostname)


        Response.Write("Your Local IP Address is:  " & localipaddresses.AddressList(0).ToString() & "</em><br />")
       

Thursday, December 9, 2010

WPF Run Exe and Open URL in a Browser Window

System.Diagnostics.Process.Start("D:\2010-2011\smcen2010\optics2010.exe")


System.Diagnostics.Process.Start("http://122.160.43.248/labpendency")

Wednesday, December 8, 2010

VB.NET Capture Client Machine Remote IP

  1. Dim strClientIP As String
  2. strClientIP = Request.UserHostAddress()
  3. Response.Write(strClientIP)

VB.NET Run exe

Dim startInfo As System.Diagnostics.ProcessStartInfo
Dim pStart As New System.Diagnostics.Process

startInfo = New System.Diagnostics.ProcessStartInfo("C:\file.exe")

pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
'Your code will halt until the exe file has executed.