Advertisement
Guest User

Function Prueba Ikillnukes

a guest
Jun 24th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.76 KB | None | 0 0
  1.     Sub prueba()
  2.  
  3.         Try
  4.  
  5.             Panel1.Visible = True
  6.             Label1.Visible = True
  7.  
  8.             With Label1
  9.  
  10.                 Windows.Forms.Cursor.Current = Cursors.WaitCursor
  11.  
  12.                 .Text = "Obteniendo y creando nuevas variables"
  13.                 Dim getname As String = WebBrowser1.Document.GetElementById("formu").GetAttribute("Name")
  14.                 Dim prueba1 As String = WebBrowser1.Document.GetElementById(getname & "-nombre").GetAttribute("Value")
  15.                 Dim prueba2 As String = WebBrowser1.Document.GetElementById(getname & "-dwl").GetAttribute("Value")
  16.                 Dim prueba6 As String = WebBrowser1.Document.GetElementById(getname & "-ver").GetAttribute("Value")
  17.                 Dim prueba7 As String = WebBrowser1.Document.GetElementById(getname & "-name").GetAttribute("Value")
  18.                 Dim prueba8 As String = WebBrowser1.Document.GetElementById(getname & "-desc").GetAttribute("Value")
  19.                 Dim prueba9 As String = WebBrowser1.Document.GetElementById(getname & "-vermc").GetAttribute("Value")
  20.                 Dim prueba10 As String = WebBrowser1.Document.GetElementById(getname & "-id").GetAttribute("Value")
  21.  
  22.                 .Text = "Comprando si el archivo Run.bat existe"
  23.                 If Not File.Exists(".\Modpacks\" & prueba1 & "\run.bat") Then
  24.  
  25.                     .Text = "Leyendo Ini"
  26.                     Dim value As String = File.ReadAllText(".\Test.ini")
  27.                     .Text = "Contando similitudes"
  28.                     Dim cuenta As Integer = Find_String_Occurrences(value, "2ç0k")
  29.                     .Text = "Creando variable"
  30.                     Dim prueba3 As String = ".\Temp\modpack-" & cuenta & ".zip"
  31.  
  32.                     .Text = "Comprobado si el archivo existe"
  33.                     If File.Exists(prueba3) Then
  34.                         .Text = "Borrando archivo para evitar conflictos"
  35.                         File.Delete(prueba3)
  36.                     End If
  37.                     .Text = "descargando Paquete de Mods: " & prueba1
  38.                     My.Computer.Network.DownloadFile(
  39.                 prueba2,
  40.                 ".\Temp\modpack-" & cuenta & ".zip")
  41.  
  42.                     .Text = "Extrayendo Paquete de Mods: " & prueba1
  43.                     Extraer.Extraer(prueba3, ".\PackMods\" & prueba1 & "\")
  44.  
  45.                     .Text = "Definiendo variable del Splash"
  46.                     Dim prueba4 As String = ".\PackMods\" & prueba1 & "\Splash.png"
  47.  
  48.                     .Text = "Introduciendo nuevos datos en el INI"
  49.                     INI_Manager.Set_Value(".\Test.ini", "Contar" & cuenta, "2ç0k")
  50.                     INI_Manager.Set_Value(".\Test.ini", "FuncId-" & cuenta, prueba10)
  51.                     INI_Manager.Set_Value(".\Test.ini", "FuncNombre-" & cuenta, prueba1)
  52.                     INI_Manager.Set_Value(".\Test.ini", "FuncImg-" & cuenta, prueba4)
  53.  
  54.                     .Text = "Creando variable"
  55.                     Dim prueba5 As String = ".\PackMods\" & prueba1 & "\run.bat"
  56.  
  57.                     .Text = "Introduciendo nuevos datos en el INI"
  58.                     INI_Manager.Set_Value(".\Test.ini", "FuncDir-" & cuenta, prueba5)
  59.                     INI_Manager.Set_Value(".\Test.ini", "FuncVer-" & cuenta, prueba6)
  60.                     INI_Manager.Set_Value(".\Test.ini", "FuncName-" & cuenta, prueba7)
  61.                     INI_Manager.Set_Value(".\Test.ini", "FuncDesc-" & cuenta, prueba8)
  62.                     INI_Manager.Set_Value(".\Test.ini", "FuncMcVer-" & cuenta, prueba9)
  63.  
  64.                     .Text = "Creando variables"
  65.                     Dim sRenglon As String = Nothing
  66.                     Dim strStreamW As Stream = Nothing
  67.                     Dim strStreamWriter As StreamWriter = Nothing
  68.                     Dim ContenidoArchivo As String = Nothing
  69.                     Dim PathArchivo As String
  70.                     Dim ObjItemtot As Integer
  71.                     Dim ObjItemtot2 As Integer
  72.  
  73.                     Try
  74.  
  75.                         PathArchivo = prueba5
  76.                         .Text = "Comprobando si el archivo existe"
  77.                         If File.Exists(PathArchivo) Then
  78.                             .Text = "Abriendo el archivo"
  79.                             strStreamW = File.Open(PathArchivo, FileMode.Open)
  80.                         Else
  81.                             .Text = "Creando archivo"
  82.                             strStreamW = File.Create(PathArchivo)
  83.                         End If
  84.  
  85.                         .Text = "Definiendo variable"
  86.                         Dim ObjItem As String
  87.                         .Text = "Obteniendo Memoria RAM disponible"
  88.                         ObjItem = Int(((My.Computer.Info.TotalPhysicalMemory) / 1048576))
  89.  
  90.                         .Text = "Definiendo tope de Memoria RAM a usar"
  91.                         ObjItemtot = ObjItem / 3
  92.  
  93.                         ObjItemtot2 = ObjItem / 4
  94.  
  95.                         .Text = "Editando archivo"
  96.                         strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.Default)
  97.  
  98.                         .Text = "Introduciendo líneas de texto dentro del archivo"
  99.                         strStreamWriter.WriteLine("@echo off")
  100.                         strStreamWriter.WriteLine("set APPDATA=" & Application.StartupPath & "\PackMods\" & prueba1)
  101.                         strStreamWriter.WriteLine("java  -Xincgc -Xmx%1m -Xms%2m -cp ""%APPDATA%\.minecraft\bin\minecraft.jar;%APPDATA%\.minecraft\bin\lwjgl.jar;%APPDATA%\.minecraft\bin\lwjgl_util.jar;%APPDATA%\.minecraft\bin\jinput.jar"" -Djava.library.path=""%APPDATA%\.minecraft\bin\natives"" net.minecraft.client.Minecraft %3")
  102.                         strStreamWriter.WriteLine("break")
  103.  
  104.                         .Text = "Cerrando el editor"
  105.                         strStreamWriter.Close()
  106.  
  107.                     Catch ex As Exception
  108.                         MsgBox("Error al Guardar la ingormacion en el archivo. " & ex.ToString, MsgBoxStyle.Critical, Application.ProductName)
  109.                         strStreamWriter.Close()
  110.                     End Try
  111.  
  112.                     .Text = "Introduciendo nuevos datos en el INI"
  113.                     INI_Manager.Set_Value(".\Test.ini", "Xmx-" & cuenta, ObjItemtot2)
  114.                     INI_Manager.Set_Value(".\Test.ini", "Xms-" & cuenta, ObjItemtot)
  115.  
  116.                     .Text = "Borrando archivos temporales"
  117.                     File.Delete(prueba3)
  118.  
  119.                     .Text = "¡" & prueba1 & " ha sido instalado correctamente!" & vbCrLf & "Muchas gracias por usar IkillLauncher"
  120.                 Else
  121.                     MsgBox("Este ModPack ya lo tienes instalado!")
  122.                 End If
  123.  
  124.             End With
  125.  
  126.         Catch ex As Exception
  127.             MsgBox(ex.Message)
  128.         End Try
  129.  
  130.         Windows.Forms.Cursor.Current = Cursors.Default
  131.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement