Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.IO.File
  4.  
  5. Public Class Form1
  6. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7. 'Creates path for output file & cmd process
  8. Dim path As String = My.Application.Info.DirectoryPath() & "\ExIpOutput.txt"
  9. Dim path1 As String = My.Application.Info.DirectoryPath() & "\Ipconfig.txt"
  10. Dim pathSub As String = path.Substring(2, 3)
  11. Dim path1Sub As String = path1.Substring(2, 3)
  12.  
  13. 'Tests for // in path(s)
  14. If pathSub = "//" Then
  15. RemoveCharacter(path, 2)
  16. Else
  17. End If
  18.  
  19. If path1Sub = "//" Then
  20. RemoveCharacter(path1, 2)
  21. Else
  22. End If
  23.  
  24. 'Creates output files
  25. Dim fs As FileStream = File.Create(path)
  26. fs.Close()
  27. Dim fs1 As FileStream = File.Create(path1)
  28. fs1.Close()
  29.  
  30. 'Appends path1 string with quotes to fix spacing
  31. Dim pathIns As String = """"
  32. Dim path1F As String = path1.Insert(0, pathIns)
  33. path1 = path1F
  34.  
  35. Dim path1FIns As Integer = path1.Length()
  36. Dim path1FF As String = path1.Insert(path1FIns, pathIns)
  37. path1 = path1FF
  38.  
  39. 'Appends path string...
  40. Dim pathF As String = path.Insert(0, pathIns)
  41. path = pathF
  42.  
  43. Dim pathFIns As Integer = path.Length()
  44. Dim pathFF As String = path.Insert(pathFIns, pathIns)
  45. path = pathFF
  46.  
  47. 'Declares the ExIP Program
  48. Dim psi As New ProcessStartInfo With {
  49. .Verb = "runas",
  50. .FileName = "Cmd",
  51. .Arguments = "/c " & "nslookup myip.opendns.com resolver1.opendns.com " & "> " & path
  52. }
  53. 'Attempts to run the program
  54. Process.Start(psi)
  55.  
  56. 'Declares the IPConf Program
  57. Dim psi1 As New ProcessStartInfo With {
  58. .Verb = "runas",
  59. .FileName = "Cmd",
  60. .Arguments = "/c " & "ipconfig /all " & "> " & path1
  61. }
  62. 'Attempts to run the program
  63. Process.Start(psi1)
  64.  
  65. End Sub
  66. Function RemoveCharacter(ByVal stringToCleanup, ByVal characterToRemove)
  67. Return stringToCleanup.Replace(characterToRemove, "")
  68. End Function
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement