Advertisement
TheVideoVolcano

Remote Shutdown Code

Mar 25th, 2013
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.58 KB | None | 0 0
  1. 'Remote Shutdown Code.
  2.  
  3. Imports Microsoft.Win32
  4.  
  5. Public Class Form1
  6.  
  7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         Timer1.Start()
  9.         Me.WindowState = FormWindowState.Minimized
  10.         Me.Visible = False
  11.         RunAtStartup(Application.ProductName, Application.ExecutablePath)
  12.         'IO.File.Move(Application.ExecutablePath, "C:\ProgramData\Remote Shutdown.exe")
  13.     End Sub
  14.  
  15.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  16.         Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("raw text link here")
  17.         Dim response As System.Net.HttpWebResponse = request.GetResponse()
  18.         Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
  19.  
  20.         Dim ExecuteShutdown As String = sr.ReadToEnd()
  21.         Dim currentversion As String = Application.ProductVersion
  22.  
  23.         If ExecuteShutdown.Contains("TRUE") Then
  24.             System.Diagnostics.Process.Start("shutdown", "-f -s -t 500")
  25.             Timer1.Stop()
  26.         End If
  27.     End Sub
  28.  
  29.     Public Sub RunAtStartup(ByVal ApplicationName As String, ByVal ApplicationPath As String)
  30.         Dim CU As Microsoft.Win32.RegistryKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
  31.         With CU
  32.             .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
  33.  
  34.             .SetValue("RemoteShutdown", "C:\ProgramData\Remote Shutdown.exe")
  35.  
  36.         End With
  37.  
  38.     End Sub
  39.  
  40. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement