FREE VB.NET SOURCE CODE

29 March, 2012

[SNP] Disable / Turn Off Windows Firewall [VB.NET]

First add this SUB to your project:

    Private Sub StopFirewall()
        Dim Program As Process = New Process
        Dim top As String = "netsh.exe"
        Program.StartInfo.Arguments = ("firewall set opmode disable")
        Program.StartInfo.FileName = top
        Program.StartInfo.UseShellExecute = False
        Program.StartInfo.RedirectStandardOutput = True
        Program.StartInfo.CreateNoWindow = True
        Program.Start()
        Program.WaitForExit()
    End Sub

Then use it like that:

    StopFirewall()

[SNP] Take Screenshot / Save Screenshot [VB.NET]

  Public Sub TakeScreenshot()  
     Try  
       Dim filename As String = System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif", ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height), screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height), g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)  
       g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)  
       If My.Computer.FileSystem.FileExists(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif") Then  
         My.Computer.FileSystem.DeleteFile(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif")  
       End If  
       screenGrab.Save(filename, System.Drawing.Imaging.ImageFormat.Gif)  
     Catch  
     End Try  
   End Sub  


This is the sub, that will get your screenshot, afterwards use this

TakeScreenshot()  
 My.Computer.FileSystem.MoveFile(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif", System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\SS.gif")  

to save your screenshot on your desktop with the name SS.gif