2011年2月5日土曜日

Check & Setting Tool 0.4.1

[2011/02/11 Update]
Public Class Form1
    Dim regget(10) As String
    Dim regpath(5) As String
    Dim servicename(6) As String
    Dim strComputer = "."
    Dim objWMIService = GetObject("winmgmts:\\" & strComputer)
    Dim colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Check & Setting Tool 0.4.1(Need Administrator)"

        TabPage1.Text = "Check & Setting"
        TabPage2.Text = "ReadMe"

        TextBox1.Text = "ComputerName"
        TextBox2.Text = "ComputerWorkgroup"
        TextBox3.Text = "RegisteredOwner"
        TextBox4.Text = "RegisteredOrganization"
        TextBox5.Text = "AutoPlay"
        TextBox6.Text = "User Account Control"
        TextBox25.Text = "Folder Option"

        Button1.Text = "Refresh"
        Button2.Text = "Default All"
        Button3.Text = "Setting"
        Button4.Text = "Setting"
        Button13.Text = "Setting"

        regpath(0) = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
        regpath(1) = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
        regpath(2) = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers"
        regpath(3) = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
        regpath(4) = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services"

        Me.Button1.PerformClick()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each objComputer In colSettings
            TextBox7.Text = objComputer.Name
            TextBox8.Text = objComputer.Workgroup
        Next

        regget(0) = My.Computer.Registry.GetValue _
                    (regpath(0), "RegisteredOwner", Nothing)
        regget(1) = My.Computer.Registry.GetValue _
                    (regpath(0), "RegisteredOrganization", Nothing)
        regget(2) = My.Computer.Registry.GetValue _
                    (regpath(1), "Hidden", Nothing)
        regget(3) = My.Computer.Registry.GetValue _
                    (regpath(1), "HideFileExt", Nothing)
        regget(4) = My.Computer.Registry.GetValue _
                    (regpath(1), "ShowSuperHidden", Nothing)
        regget(5) = My.Computer.Registry.GetValue _
                    (regpath(1), "SeparateProcess", Nothing)
        regget(6) = My.Computer.Registry.GetValue _
                    (regpath(1), "ShowCompColor", Nothing)
        regget(7) = My.Computer.Registry.GetValue _
                    (regpath(1), "SharingWizardOn", Nothing)
        regget(8) = My.Computer.Registry.GetValue _
                    (regpath(2), "DisableAutoplay", Nothing)
        regget(9) = My.Computer.Registry.GetValue _
                    (regpath(3), "EnableLUA", Nothing)

        TextBox9.Text = regget(0)
        TextBox10.Text = regget(1)

        If regget(2) = 1 And _
            regget(3) = 0 And _
            regget(4) = 1 And _
            regget(5) = 1 And _
            regget(6) = 0 And _
            regget(7) = 0 Then
            TextBox26.Text = "Default Setting"
        Else
            TextBox26.Text = "User Setting"
        End If

        If regget(8) = 1 Then
            TextBox11.Text = "Disabled"
            Button5.Text = "Enabled"
        ElseIf regget(8) = 0 Then
            TextBox11.Text = "Enabled"
            Button5.Text = "Disabled"
        End If

        If regget(9) = 0 Then
            TextBox12.Text = "Disabled"
            Button6.Text = "Enabled"
        ElseIf regget(9) = 1 Then
            TextBox12.Text = "Enabled"
            Button6.Text = "Disabled"
        End If

        servicename(0) = "WinDefend"
        servicename(1) = "MpsSvc"
        servicename(2) = "Themes"
        servicename(3) = "AudioSrv"
        servicename(4) = "wscsvc"
        servicename(5) = "WSearch"
        For i = 0 To 5 Step 1
            If My.Computer.Registry.GetValue _
               (regpath(4) & "\" & servicename(i), _
               "DisplayName", Nothing) Is Nothing Then
                Select Case servicename(i)
                    Case servicename(0)
                        TextBox13.Text = "No Service"
                        TextBox19.Text = "No Service"
                        Button7.Text = "No Service"
                        Button7.Enabled = False
                    Case servicename(1)
                        TextBox14.Text = "No Service"
                        TextBox20.Text = "No Service"
                        Button8.Text = "No Service"
                        Button8.Enabled = False
                    Case servicename(2)
                        TextBox15.Text = "No Service"
                        TextBox21.Text = "No Service"
                        Button9.Text = "No Service"
                        Button9.Enabled = False
                    Case servicename(3)
                        TextBox16.Text = "No Service"
                        TextBox22.Text = "No Service"
                        Button10.Text = "No Service"
                        Button10.Enabled = False
                    Case servicename(4)
                        TextBox17.Text = "No Service"
                        TextBox23.Text = "No Service"
                        Button11.Text = "No Service"
                        Button11.Enabled = False
                    Case servicename(5)
                        TextBox18.Text = "No Service"
                        TextBox24.Text = "No Service"
                        Button12.Text = "No Service"
                        Button12.Enabled = False
                End Select
            Else
                Select Case servicename(i)
                    Case servicename(0)
                        Dim WinDefend = objWMIService.Get _
                        ("Win32_Service.Name='WinDefend'")
                        TextBox13.Text = WinDefend.DisplayName
                        TextBox19.Text = WinDefend.StartMode & "," & WinDefend.State()
                        If WinDefend.StartMode = "Disabled" Then
                            Button7.Text = "Auto"
                        ElseIf WinDefend.StartMode = "Auto" Then
                            Button7.Text = "Disabled"
                        End If
                    Case servicename(1)
                        Dim MpsSvc = objWMIService.Get _
                        ("Win32_Service.Name='MpsSvc'")
                        TextBox14.Text = MpsSvc.DisplayName
                        TextBox20.Text = MpsSvc.StartMode & "," & MpsSvc.State()
                        If MpsSvc.StartMode = "Disabled" Then
                            Button8.Text = "Auto"
                        ElseIf MpsSvc.StartMode = "Auto" Then
                            Button8.Text = "Disabled"
                        End If
                    Case servicename(2)
                        Dim Themes = objWMIService.Get _
                        ("Win32_Service.Name='Themes'")
                        TextBox15.Text = Themes.DisplayName
                        TextBox21.Text = Themes.StartMode & "," & Themes.State()
                        If Themes.StartMode = "Disabled" Then
                            Button9.Text = "Auto"
                        ElseIf Themes.StartMode = "Auto" Then
                            Button9.Text = "Disabled"
                        End If
                    Case servicename(3)
                        Dim AudioSrv = objWMIService.Get _
                        ("Win32_Service.Name='AudioSrv'")
                        TextBox16.Text = AudioSrv.DisplayName
                        TextBox22.Text = AudioSrv.StartMode & "," & AudioSrv.State()
                        If AudioSrv.StartMode = "Disabled" Then
                            Button10.Text = "Auto"
                        ElseIf AudioSrv.StartMode = "Auto" Then
                            Button10.Text = "Disabled"
                        End If
                    Case servicename(4)
                        Dim wscsvc = objWMIService.Get _
                        ("Win32_Service.Name='wscsvc'")
                        TextBox17.Text = wscsvc.DisplayName
                        TextBox23.Text = wscsvc.StartMode & "," & wscsvc.State
                        If wscsvc.StartMode = "Disabled" Then
                            Button11.Text = "Auto"
                        ElseIf wscsvc.StartMode = "Auto" Then
                            Button11.Text = "Disabled"
                        End If
                    Case servicename(5)
                        Dim WSearch = objWMIService.Get _
                        ("Win32_Service.Name='WSearch'")
                        TextBox18.Text = WSearch.DisplayName
                        TextBox24.Text = WSearch.StartMode & "," & WSearch.State
                        If WSearch.StartMode = "Disabled" Then
                            Button12.Text = "Auto"
                        ElseIf WSearch.StartMode = "Auto" Then
                            Button12.Text = "Disabled"
                        End If
                End Select
            End If
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim RegisteredOwner As String
        RegisteredOwner = TextBox9.Text
        My.Computer.Registry.SetValue _
        (regpath(0), "RegisteredOwner", RegisteredOwner, Microsoft.Win32.RegistryValueKind.String)
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim RegisteredOrganization As String
        RegisteredOrganization = TextBox10.Text
        My.Computer.Registry.SetValue _
        (regpath(0), "RegisteredOrganization", RegisteredOrganization, Microsoft.Win32.RegistryValueKind.String)
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If regget(8) = 0 Then
            My.Computer.Registry.SetValue _
            (regpath(2), "DisableAutoplay", "1", Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf regget(8) = 1 Then
            My.Computer.Registry.SetValue _
            (regpath(2), "DisableAutoplay", "0", Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If regget(9) = 1 Then
            My.Computer.Registry.SetValue _
            (regpath(3), "EnableLUA", "0", Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf regget(9) = 0 Then
            My.Computer.Registry.SetValue _
            (regpath(3), "EnableLUA", "1", Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If Button7.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\WinDefend", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button7.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\WinDefend", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        If Button8.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\MpsSvc", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button8.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\MpsSvc", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        If Button9.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\Themes", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button9.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\Themes", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        If Button10.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\AudioSrv", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button10.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\AudioSrv", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        If Button11.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\wscsvc", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button11.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\wscsvc", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        If Button12.Text = "Auto" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\WSearch", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        ElseIf Button12.Text = "Disabled" Then
            My.Computer.Registry.SetValue _
            (regpath(4) & "\WSearch", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        End If
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        My.Computer.Registry.SetValue _
        (regpath(1), "Hidden", "1", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(1), "HideFileExt", "0", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(1), "ShowSuperHidden", "1", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(1), "SeparateProcess", "1", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(1), "ShowCompColor", "0", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(1), "SharingWizardOn", "0", Microsoft.Win32.RegistryValueKind.DWord)
        Me.Button1.PerformClick()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        My.Computer.Registry.SetValue _
        (regpath(0), "RegisteredOwner", "Belldandy", Microsoft.Win32.RegistryValueKind.String)
        My.Computer.Registry.SetValue _
        (regpath(0), "RegisteredOrganization", "Syaorin", Microsoft.Win32.RegistryValueKind.String)
        My.Computer.Registry.SetValue _
        (regpath(2), "DisableAutoplay", "1", Microsoft.Win32.RegistryValueKind.DWord)
        My.Computer.Registry.SetValue _
        (regpath(3), "EnableLUA", "0", Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox13.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\WinDefend", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox14.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\MpsSvc", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox15.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\Themes", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox16.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\AudioSrv", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox17.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\wscsvc", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
        If Not TextBox18.Text = "No Service" Then My.Computer.Registry.SetValue _
        (regpath(4) & "\WSearch", "Start", 2, Microsoft.Win32.RegistryValueKind.DWord)
        Me.Button13.PerformClick()
    End Sub
End Class

0 件のコメント: