Skip to content

Instantly share code, notes, and snippets.

@Laim
Last active February 12, 2022 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laim/e7407cf24c0587119da4606a566a9a71 to your computer and use it in GitHub Desktop.
Save Laim/e7407cf24c0587119da4606a566a9a71 to your computer and use it in GitHub Desktop.
winRekt
Option Explicit On
Imports System.IO
Imports System
Imports System.Text
Public Class Form1
''
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_UPDATEINIFILE = &H1
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
''
Dim amount As Integer
Dim startTime As DateTime
Dim endTime As DateTime
Dim TotalTime As TimeSpan
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
'' Move the Wallpaper folder to the C Drive ''
startTime = Date.Now
Dim counter As Integer
Dim complete As Integer
Dim fileName As String
''
If txtRektAmount.Text = "" Then
txtRektAmount.Text = "100"
End If
counter = txtRektAmount.Text
If My.Settings.debugMode = True Then
fileName = "logs/creation/log_" & DateTime.Today.ToString("dd-MMM-yyyy") & ".txt"
Dim strFile As String = String.Format(fileName, DateTime.Today.ToString("dd-MMM-yyyy"))
Dim strContents As String = String.Format("File Rekt_" & complete & " created at: {0}{1}", DateTime.Now, Environment.NewLine & Environment.NewLine)
Do Until complete = counter
amount = 100 / counter
complete = complete + 1
ProgressBar1.Value = ProgressBar1.Value + amount
If IO.Directory.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt") Then
rekt(complete)
File.AppendAllText(strFile, strContents)
Else
IO.Directory.CreateDirectory(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt")
rekt(complete)
File.AppendAllText(strFile, strContents)
End If
Loop
File.AppendAllText(strFile, String.Format("Debug Stats:" & Environment.NewLine))
File.AppendAllText(strFile, String.Format("Finish Time: " + TotalTime.Seconds.ToString + " Seconds" & Environment.NewLine))
File.AppendAllText(strFile, String.Format("Files Created: " + System.IO.Directory.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt/").Length.ToString & Environment.NewLine))
endTime = Date.Now
TotalTime = endTime - startTime
End If
MsgBox("The Rekoning has been completed in " + TotalTime.Seconds.ToString + " Seconds")
ProgressBar1.Value = 0
End Sub
Private Sub rekt(ByVal complete)
If Not File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt/rekt_" & complete & ".txt") Then
' Create a file to write to.
Using sw As StreamWriter = File.CreateText(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt/rekt_" & complete & ".txt")
sw.WriteLine("Welcome " + Environment.UserName + ", to the Rekoning.")
sw.WriteLine("You have been rekt on " + Date.Now)
sw.WriteLine("Remember to log out next time!")
sw.WriteLine("")
sw.WriteLine(My.Settings.rekText)
End Using
End If
End Sub
Private Sub txtRektAmount_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtRektAmount.TextChanged
If txtRektAmount.Text = "" Or "0" Then
lblSizeValue.Text = "0KB"
Else
Dim sizeBits As Integer
Dim sizeBytes As Integer
Dim sizeKBytes As Integer
sizeBits = txtRektAmount.Text * 12808
sizeBytes = sizeBits / 8
sizeKBytes = sizeBytes / 1024
lblSizeValue.Text = sizeKBytes & "KB"
End If
End Sub
Private Sub btnDefault_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDefault.Click
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\wallpapers\LA_WALLPAPER.jpg", SPIF_UPDATEINIFILE)
End Sub
Private Sub btnGaben_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGaben.Click
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\wallpapers\GABE_WALLPAPER.jpg", SPIF_UPDATEINIFILE)
End Sub
Private Sub btnABORT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnABORT.Click
If Directory.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt") Then
For Each i In System.IO.Directory.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt")
File.Delete(i)
Next
Directory.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop + "/rekt")
Else
''
End If
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\wallpapers\LA_WALLPAPER.jpg", SPIF_UPDATEINIFILE)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Directory.Exists("C:\wallpapers") Then
For Each i In System.IO.Directory.GetFiles("C:\wallpapers")
File.Delete(i)
Next
Directory.Delete("C:\wallpapers")
Else
Directory.CreateDirectory("C:\wallpapers")
My.Computer.FileSystem.CopyDirectory("wallpapers", "C:\wallpapers", True)
End If
If My.Settings.debugMode = False Then
btnDebug.Text = "Debug Mode: OFF"
ElseIf My.Settings.debugMode = True Then
btnDebug.Text = "Debug Mode: ON"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeText.Click
Form2.Show()
End Sub
Private Sub btnDebug_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDebug.Click
If btnDebug.Text.Contains("ON") Then
My.Settings.debugMode = False
My.Settings.Save()
btnDebug.Text = "Debug Mode: OFF"
ElseIf btnDebug.Text.Contains("OFF") Then
My.Settings.debugMode = True
My.Settings.Save()
btnDebug.Text = "Debug Mode: ON"
'' START THE LOG ''
End If
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment