Advertisement
Guest User

Full VB.NET Code for Launcher

a guest
Sep 22nd, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Text
  4. Imports System.Text.RegularExpressions
  5. Public Class Form1
  6. #Region "ServerConfig"
  7.     Dim ServerIP As String = "192.168.1.44"
  8.     Dim ClientExe As String = "Phoenix.exe"
  9.     Dim Login As String = "http://192.168.1.44/Login/"
  10.     Dim Homepage As String = "http://fiesta.pephix.square7.net/"
  11.     Dim Register As String = "http://fiesta.pephix.square7.net/"
  12.  
  13.     Dim cpx, cpy As Int32
  14.     Friend WithEvents Downloader As New Net.WebClient
  15.     Dim wc As New WebClient
  16.     Dim Encrypt As New Encrypt
  17.     Dim ClientConfig As String() = Nothing
  18.     Dim PatchList As String() = Nothing
  19. #End Region
  20.     Private Sub Download()
  21.         If SV.Text = CV.Text Then
  22.             PBLaunch.Enabled = True
  23.             StatusLabel.Text = "Client has been updated."
  24.             PPLabel.Hide()
  25.         ElseIf Val(CV.Text) > Val(SV.Text) Then
  26.             MessageBox.Show("An Error occured. The Launcher will restart now.", "Error 1 - Client Overpatched", MessageBoxButtons.OK, MessageBoxIcon.Error)
  27.             Directory.Delete("Launcher", True)
  28.             Application.Restart()
  29.         Else
  30.             StatusLabel.Text = "Downloading Patch " & Val(CV.Text) + Val(1) & "..."
  31.             ProgressBar.Value = 0
  32.             Downloader.DownloadFileAsync(New Uri(PatchList(Val(CV.Text) + Val(1)).Split(vbTab)(1)), "Patch.rar")
  33.         End If
  34.     End Sub
  35.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  36.         'If File.Exists("Updater.exe") Then
  37.        '    File.Delete("Updater.exe")
  38.        'End If
  39.        'If Downloader.DownloadString("http://192.168.1.44:1234/login/version.txt") <> FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion Then
  40.        '    My.Computer.Network.DownloadFile("http://192.168.1.44:1234/login/Updater.exe", "Updater.exe")
  41.        '    Process.Start("Updater.exe")
  42.        '    Application.Exit()
  43.        '    End
  44.        'End If
  45.        If Not File.Exists("UnRAR.exe") Then
  46.             My.Computer.Network.DownloadFile(Login & "UnRAR.exe", "UnRAR.exe")
  47.         End If
  48.         If Not File.Exists("Launcher/information.info") Then
  49.             Directory.CreateDirectory("Launcher")
  50.             File.WriteAllText("Launcher/information.info", Encrypt.Encrypt("Version=0"))
  51.         End If
  52.         TBUser.Select()
  53.         ClientConfig = IO.File.ReadAllLines("Launcher/information.info")
  54.         ClientConfig(0) = Encrypt.Decrypt(ClientConfig(0))
  55.         PatchList = wc.DownloadString(Login & "patch_list.txt").Split(vbNewLine)
  56.         CV.Text = ClientConfig(0).Split("=")(1)
  57.         SV.Text = Encrypt.CountPatches(Login & "patch_list.txt")
  58.  
  59.         Download()
  60.     End Sub
  61.     Private Sub Downloader_Completed(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles Downloader.DownloadFileCompleted
  62.         StatusLabel.Text = "Extracting Patch " & CV.Text & "..."
  63.         CV.Text = Val(CV.Text) + Val(1)
  64.         Dim Process As Process
  65.         Dim ProcessStartInfo As New ProcessStartInfo
  66.         Me.Refresh()
  67.         ProcessStartInfo.FileName = "UnRAR.exe"
  68.         ProcessStartInfo.Arguments = "x -y -ac Patch.rar"
  69.         ProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden
  70.         Process = Process.Start(ProcessStartInfo)
  71.         Process.WaitForExit()
  72.         File.Delete("Patch.rar")
  73.         IO.File.WriteAllText("Launcher/information.info", Encrypt.Encrypt("ClientVersion=" & CV.Text))
  74.         Download()
  75.     End Sub
  76.     Private Sub Downloader_Progress(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles Downloader.DownloadProgressChanged
  77.         PBProgressFill.Width = PBProgressEmpty.Width * ProgressBar.Value / 100
  78.         PPLabel.Text = e.ProgressPercentage & "%"
  79.         ProgressBar.Value = e.ProgressPercentage
  80.     End Sub
  81.     Private Sub Form1_FormClosed(sender As System.Object, e As System.EventArgs) Handles MyBase.Closed
  82.         NotifyIcon1.Visible = False
  83.         NotifyIcon1.Dispose()
  84.         NotifyIcon1 = Nothing
  85.     End Sub
  86.     Private Sub PBLaunch_Click(sender As System.Object, e As System.EventArgs) Handles PBLaunch.Click
  87.         Dim MD5Pass As String = Encrypt.MD5StringHash(TBPass.Text)
  88.         Dim wc As WebClient = New WebClient()
  89.         Dim Log As String = wc.DownloadString(Login & "Login.php?Username=" & TBUser.Text & "&Password=" & MD5Pass.ToLower())
  90.         If Log.Contains("OK") Then
  91.             Process.Start(ClientExe, "-osk_server " & ServerIP & " -osk_token " & Log.Split("#")(1) & " -osk_store " & Homepage)
  92.             Application.Exit()
  93.         Else
  94.             MessageBox.Show("Wrong Username or Password. Please try again.", "Login Error 1 - Wrong Credentials", MessageBoxButtons.OK, MessageBoxIcon.Error)
  95.         End If
  96.     End Sub
  97. #Region "Button Müll"
  98.     Private Sub PBRegister_Click(sender As System.Object, e As System.EventArgs) Handles PBRegister.Click
  99.         Process.Start(Register)
  100.     End Sub
  101.     Private Sub PBHomepage_Click(sender As System.Object, e As System.EventArgs) Handles PBHomepage.Click
  102.         Process.Start(Homepage)
  103.     End Sub
  104.     Private Sub PBExit_Click(sender As System.Object, e As System.EventArgs) Handles PBExit.Click
  105.         Application.Exit()
  106.     End Sub
  107.     Private Sub PBPatch_Click(sender As System.Object, e As System.EventArgs) Handles PBPatch.Click
  108.         Directory.Delete("Launcher", True)
  109.         Application.Restart()
  110.     End Sub
  111. #End Region
  112. #Region "Button Hover"
  113.     Private Sub PBLaunch_Hover(sender As System.Object, e As System.EventArgs) Handles PBLaunch.MouseHover
  114.         PBLaunch.Image = My.Resources.PephixStartMouse
  115.     End Sub
  116.     Private Sub PBLaunch_Leave(sender As System.Object, e As System.EventArgs) Handles PBLaunch.MouseLeave
  117.         PBLaunch.Image = My.Resources.PephixStart
  118.     End Sub
  119.     Private Sub PBRegister_Hover(sender As System.Object, e As System.EventArgs) Handles PBRegister.MouseHover
  120.         PBRegister.Image = My.Resources.PephixRegisterMouse
  121.     End Sub
  122.     Private Sub PBRegister_Leave(sender As System.Object, e As System.EventArgs) Handles PBRegister.MouseLeave
  123.         PBRegister.Image = My.Resources.PephixRegister
  124.     End Sub
  125.     Private Sub PBHomepage_Hover(sender As System.Object, e As System.EventArgs) Handles PBHomepage.MouseHover
  126.         PBHomepage.Image = My.Resources.PephixHomeMouse1
  127.     End Sub
  128.     Private Sub PBHomepage_Leave(sender As System.Object, e As System.EventArgs) Handles PBHomepage.MouseLeave
  129.         PBHomepage.Image = My.Resources.PephixHome1
  130.     End Sub
  131.     Private Sub PBPatch_Hover(sender As System.Object, e As System.EventArgs) Handles PBPatch.MouseHover
  132.         PBPatch.Image = My.Resources.PephixPatchMouse
  133.     End Sub
  134.     Private Sub PBPatch_Leave(sender As System.Object, e As System.EventArgs) Handles PBPatch.MouseLeave
  135.         PBPatch.Image = My.Resources.PephixPatch
  136.     End Sub
  137.     Private Sub PBExit_Hover(sender As System.Object, e As System.EventArgs) Handles PBExit.MouseHover
  138.         PBExit.Image = My.Resources.PephixExitMouse
  139.     End Sub
  140.     Private Sub PBExit_Leave(sender As System.Object, e As System.EventArgs) Handles PBExit.MouseLeave
  141.         PBExit.Image = My.Resources.PephixExit
  142.     End Sub
  143. #End Region
  144. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement