Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

SYS-UPDATE.vb 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Imports System.IO
  2. Public Class SYS_UPDATE
  3. ReadOnly ds2 As New DataSet
  4. Dim Str As String = Application.StartupPath
  5. Private Sub SYS_UPDATE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  6. 資料數 = 6
  7. MyModule1.進度條() : Target = "https://gcm-smart.com/ERP/YD-ERP/"
  8. End Sub
  9. Private Sub SYS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  10. MyModule1.進度條() : Delay(30000)
  11. MyModule1.進度條() : Dim Str As String = Application.StartupPath
  12. Timer1.Enabled = True
  13. End Sub
  14. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  15. Dim 已開啟 As Boolean = False
  16. Dim Strs As String = Application.StartupPath
  17. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\YD-ERP-SYS.exe") Then
  18. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  19. ' 判斷是否有符合的Process
  20. For Each process As Process In pro
  21. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  22. 已開啟 = True
  23. End If
  24. Next
  25. If 已開啟 = False Then
  26. Timer1.Enabled = False
  27. MyModule1.進度條() : If File.Exists(Str + "\YD-ERP-SYS.exe") Then : File.Delete(Str + "\YD-ERP-SYS.exe") : End If
  28. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & "YD-ERP-SYS.exe", Str + "\YD-ERP-SYS.exe")
  29. MyModule1.進度條() : Shell(Str + "\YD-ERP-SYS.exe", vbNormalFocus)
  30. Me.Close()
  31. End If
  32. ElseIf File.Exists(Strs & "\YD-ERP-SYS.exe") Then
  33. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  34. ' 判斷是否有符合的Process
  35. For Each process As Process In pro
  36. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  37. 已開啟 = True
  38. End If
  39. Next
  40. If 已開啟 = False Then
  41. Timer1.Enabled = False
  42. MyModule1.進度條() : If File.Exists(Str + "\YD-ERP-SYS.exe") Then : File.Delete(Str + "\YD-ERP-SYS.exe") : End If
  43. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & "/" & "YD-ERP-SYS.exe", Str + "\YD-ERP-SYS.exe")
  44. MyModule1.進度條() : Shell(Str + "\YD-ERP-SYS.exe", vbNormalFocus)
  45. Me.Close()
  46. End If
  47. End If
  48. End Sub
  49. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  50. Dim time As DateTime = DateTime.Now
  51. Dim Span As Double = Interval * 1234
  52. While ((DateTime.Now.Ticks - time.Ticks) < Span)
  53. Application.DoEvents()
  54. End While
  55. End Sub
  56. End Class