1. Tải bản cài đặt AutoIT mới nhất

    Chào Khách. Nếu bạn mới tham gia và chưa cài đặt AutoIT.
    Vui lòng vào topic trên để tải bản AutoIT mới nhất nhé
    Dismiss Notice
  2. Quy định và nội quy

    Chào Khách. Vui lòng đọc kỹ nội quy và quy định của diễn đàn
    Để tránh bị ban một cách đáng tiếc nhé!
    Dismiss Notice
  3. Hướng dẫn chèn mã AutoIT trong diễn đàn

    Chào Khách. Vui lòng xem qua bài viết này
    Để biết cách chèn mã AutoIT trong diễn đàn bạn nhé :)
    Dismiss Notice

Hỏi đáp [Solved] Xin giúp đỡ hoàn thiện code về Window Services

Thảo luận trong 'Thảo luận chung - Hỏi đáp' bắt đầu bởi khidotdn, 27/2/16.

Trạng thái chủ đề:
Không mở trả lời sau này.
  1. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    Mình đang làm 1 code optimize windows ( tinh chỉnh ) chạy được trên hệ điều hành XP , win 7, win 8, và win 10. Code thì vẫn chạy được, nhưng có 1 vấn đề là nó bất tiện trong 1 số trường hợp, nên mình nhờ các bạn giúp mình thực hiện vấn đề như sau:
    1 - Khi nhấn Button Kiểm tra xong, nó hiện trạng thái những services mà mình đã liệt kê sẵn.
    2 - Bên trái mỗi Services có Check Box
    3 - Check vào Services và Enable hoặc Disable
    4 - Khi nhấn vào Button Enable hoặc Disable nó sẽ hiện ra 1 Box thể hiện tiến trình Enable hay Disable Services đó
    Đây là code của mình:

    Mã (AutoIt):
    #include <ProgressConstants.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <MsgBoxConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <StaticConstants.au3>
    #include <Process.au3>
    #include <ScrollBarConstants.au3>
    #include <GuiEdit.au3>
    #include <InetConstants.au3>
    Dim $adrivearray[100], $Var = False, $TempDir = @TempDir & "\"
    Dim $aRegKeys[28]
    Dim $drivearray[100]
    Dim $MyServices
    Dim $MyServicesList
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Optimize v2.2.0 by OSTEAM | Áp dụng cho Windows 7 & WindowsXP", 611, 497, 190, 125)
    $ListView1 = GUICtrlCreateListView("   Service                                                                                  |Status                           |               ", 8, 8, 460, 450, $LVS_NOSORTHEADER+$LVS_SINGLESEL,$LVS_EX_GRIDLINES )
    $opt = GUICtrlCreateButton("Optimize", 470, 68, 133, 59)
    $msconfig = GUICtrlCreateButton("Msconfig", 470, 131, 133, 59)
    $driver = GUICtrlCreateButton("Device Manager", 470, 193, 133, 59)
    $chkdsk = GUICtrlCreateButton("Check Disk", 470, 255, 133, 59)
    $chip = GUICtrlCreateButton("3D Chip", 470, 316, 133, 59)
    $hwinfo = GUICtrlCreateButton("Kiểm tra Hardware", 470, 377, 133, 59)
    $testcpu = GUICtrlCreateButton("TEST CPU - VGA ", 470, 437, 133, 59)
    $ktra = GUICtrlCreateButton("Kiểm tra Services", 470, 7, 133, 59)
    $Progress1 = GUICtrlCreateProgress(8, 460, 460, 33)
    GUISetState(@SW_SHOW, $Form1)

    #EndRegion ### END Koda GUI section ###
          $MyServices = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
          $MyServicesList = $MyServices.ExecQuery("SELECT * FROM Win32_Service")

    While 1
            Switch GUIGetMsg()


    Case $ktra
       ;----Windows Update---------------------
    $myServiceQuery = "Windows Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
    ;----Computer Browser-----
    $myServiceQuery = "Computer Browser"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Bluetooth Support Service-----
    $myServiceQuery = "Bluetooth Support Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----DHCP Client-----
    $myServiceQuery = "DHCP Client"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Google Update Service (gupdate)-----
    $myServiceQuery = "Google Update Service (gupdate)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Google Update Service (gupdatem)-----
    $myServiceQuery = "Google Update Service (gupdatem)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Print Spooler-----
    $myServiceQuery = "Print Spooler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Skype Update-----
    $myServiceQuery = "Skype Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Disk Defragmenter-----
    $myServiceQuery = "Disk Defragmenter"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Desktop Window Manager Session Manager-----
    $myServiceQuery = "Desktop Window Manager Session Manager"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Task Scheduler-----
    $myServiceQuery = "Task Scheduler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
        ;----UPnP Device Host-----
    $myServiceQuery = "UPnP Device Host"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Defender-----
    $myServiceQuery = "Windows Defender"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Firewall-----
    $myServiceQuery = "Windows Firewall"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Search-----
    $myServiceQuery = "Windows Search"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Windows Search-----
    $myServiceQuery = "WLAN AutoConfig"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Wireless Zero Configuration WinXP-----
    $myServiceQuery = "Wireless Zero Configuration"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Windows FireWall/Internet Connection Sharing(ICS) WinXP-----
    $myServiceQuery = "Windows FireWall/Internet Connection Sharing(ICS)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----QoS RSUP WinXP------
    $myServiceQuery = "QoS RSUP"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Superfetch------
    $myServiceQuery = "Superfetch"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------Visual Effects
         $myServiceQuery = "WinHTTP Web Proxy Auto-Discovery Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------Visual Effects
    $FW = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting")
    If $FW = 0 Then
       $FW = "Let Windows choose what's best for my computer "
    EndIf
    If $FW = 1 Then
       $FW = "Adjust for best appearance"
    EndIf
    If $FW = 2 Then
       $FW = "Adjust for best Performance "
    EndIf
    If $FW = 3 Then
       $FW = "Custom"
    EndIf
    GUICtrlCreateListViewItem("Visual Effects" & "|" & $FW & "|" & "System", $ListView1)

    ;---------PagingFiles--------
    $FW1 = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles")
    If $FW1 = "?:\pagefile.sys" Then
       $FW1 = "Automatically manage paging file size for all drivers"
    EndIf
    If $FW1 = "c:\pagefile.sys 4096 4096" Then
       $FW1 = "Custom Size :C:\4096 4096"
    EndIf
    If $FW1 = "c:\pagefile.sys 0 0" Then
       $FW1 = "System manged size"
    EndIf
    If $FW1 = "" Then
       $FW1 = "C:\None"
    EndIf
    GUICtrlCreateListViewItem("Paging Files" & "|" & $FW1 & "|" & "System", $ListView1)

    ;---------Automatically restart----
    $FW2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "AutoReboot")
    If $FW2 = 0 Then
       $FW2 = "Disable"
    EndIf
    If $FW2 = 1 Then
       $FW2 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("Automatically restart" & "|" & $FW2 & "|" & "System", $ListView1)
    ;---------Write debugging infomation----
    $FW4 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "CrashDumpEnabled")
    If $FW4 = 0 Then
       $FW4 = "(None)"
    EndIf
    If $FW4 = 3 Then
       $FW4 = "Small memory dump (256KB)"
    EndIf
    If $FW4 = 2 Then
       $FW4 = "Kernel memory dump"
    EndIf
    GUICtrlCreateListViewItem("Write debugging infomation" & "|" & $FW4 & "|" & "System", $ListView1)
    ;---------Write an event to the system log----
    $FW5 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "LogEvent")
    If @OSArch = "X64" Then
       EndIf
    If $FW5 = 0 Then
       $FW5 = "Disable"
    EndIf
    If $FW5 = 1 Then
       $FW5 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("Write an event to the system log" & "|" & $FW5 & "|" & "System", $ListView1)
    ;---------ComputerRestore----
    $FW3 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval")
    If @OSArch = "X64" Then
       EndIf
    If $FW3 = 0 Then
       $FW3 = "Disable"
    EndIf
    If $FW3 = 1 Then
       $FW3 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("Computer Restore" & "|" & $FW3 & "|" & "System", $ListView1)

    Case $opt
          Local $sService,$sCMD,$xCMD,$vCMD,$sListService=StringSplit("wuauserv|NVSvc|FontCache3.0.0.0|WPFFontCache_v0400|NvNetworkService|GfExperienceService|NvStreamSvc|WajaIntEn Monitor|PnkBstrA|AMD External Events Utility|odserv|idsvc|MozillaMaintenance|Stereo Service|nvsvc|igfxCUIService1.0.0.0|ICCS|cphs|LMS|jhi_service|Intel(R) Capability Licensing Service TCP IP Interface|Intel(R) Capability Licensing Service Interface|WinHttpAutoProxySvc|SysMain|MpsSvc|WSearch|WinDefend|gupdate|gupdatem|UxSms|BstHdUpdaterSvc|defragsvc|Browser|upnphost|Spooler|Schedule|TabletInputService|Wlansvc|bthserv|srservice|uxsms|WZCSVC|SharedAccess","|")
    For $i=1 to UBound($sListService)-1
        $sService=$sListService[$i]
          GUICtrlSetData($Progress1,$i*5)
        ConsoleWrite(">! Stoping service: "&$sService&@CRLF)
        RunWait('"'&@ComSpec&'" /c sc config "'&$sService&'" start= DEMAN',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc config Dhcp start= auto',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net start Dhcp',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set AutoReboot = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set WriteToSystemLog = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set DebugInfoType = 0',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c schtasks /delete /tn * /f',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c bcdedit /timeout 0',@SystemDir,@SW_HIDE)
        ConsoleWrite($sService&" disabled."&@CRLF)

    Next


    ;-----------------------------VisualEffects
    Local $sRegKey = "\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
    If @OSArch = "X64" Then
        $sRegKey = "HKCU64" & $sRegKey
    Else
        $sRegKey = "HKCU" & $sRegKey
    EndIf
    RegWrite($sRegKey, "VisualFXSetting", "REG_DWORD", "2")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey
    EndIf
    RegWrite($sRegKey, "RPSessionInterval", "REG_DWORD", "0")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegDelete($sRegKey)

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegWrite($sRegKey)

    ;-----------------------------PagingFiles
    Local $sRegKey = "\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "PagingFiles", "REG_MULTI_SZ", "C:\pagefile.sys 4096 4096")

    ;-----------------------------UAC
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "EnableLUA", "REG_DWORD", "0")

    ;-----------------------------USB Root Hub Power Management
    Local $sRegKey = "\HKLM\SYSTEM\CurrentControlSet\Services\USB"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "DisableSelectiveSuspend", "REG_DWORD", "1")

    ;-----------------------------Task Scheduler
    Local $sRegKey = "\SYSTEM\CurrentControlSet\services\Schedule"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "Start", "REG_DWORD", "4")

    ;-----------------------------Msconfig

        $aRegKeys[0] = "IMJPMIG"
        $aRegKeys[1] = "CocCoc Update"
        $aRegKeys[2] = "Intel(R) Common User Interface"
        $aRegKeys[3] = "Java Platform SE Auto Updater"
        $aRegKeys[4] = "IgfxTray"
        $aRegKeys[5] = "HotKeysCmds"
        $aRegKeys[6] = "Vmware User process"
        $aRegKeys[7] = "ImScInst"
        $aRegKeys[8] = "hkcmd"
        $aRegKeys[9] = "igfxpers"
        $aRegKeys[10] = "StartCCC"
        $aRegKeys[11] = "USB3MON"
        $aRegKeys[12] = "CuHanhPlay"
        $aRegKeys[13] = "SynTPEnh"
        $aRegKeys[14] = "Quicktime Task"
        $aRegKeys[15] = "iTunesHelper"
        $aRegKeys[16] = "NvBackend"
        $aRegKeys[17] = "NvMctray"
        $aRegKeys[18] = "Persistence"
        $aRegKeys[19] = "SunJavaUpdateSched"
        $aRegKeys[20] = "ctfmon.exe"
        $aRegKeys[21] = "NvCpl"
        $aRegKeys[22] = "TINTSETP"
        $aRegKeys[23] = "jusched"
        $aRegKeys[24] = "CocCoc"
        $aRegKeys[25] = "IMEKRMIG"
        $aRegKeys[26] = "CCleaner Monitoring"
        $aRegKeys[27] = "Google Update"

        ; Loop to delete startup registry keys
        #requireAdmin
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
             ; Loop to delete startup registry keys
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
    ;-----------------------------MsgBox
    MsgBox($MB_SYSTEMMODAL, "Hoàn thành", "Hoàn thành !")
    Case $msconfig
        Run(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSCONFIG.EXE",""))
        __Run("msconfig")

    Func __Run($s_program, $s_workdir = "", $i_show = @SW_SHOW, $i_opt_flag = 0)

        If @OSArch = "X86" Then
            Return Run($s_program, $s_workdir, $i_show, $i_opt_flag)
        EndIf

        Local $t_int = DllStructCreate("int")
        Local $p_int = DllStructGetPtr($t_int)

        DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $p_int)
        Local $i_pid = Run($s_program, $s_workdir, $i_show, $i_opt_flag)
        DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $p_int)

        Return $i_pid
    EndFunc
    ;--------------- Device Manager----------
    Case $driver
        Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE)
    ;----------------Check Disk-------------
    Case $chkdsk
    ShellExecute(@WindowsDir & "\CheckDisk.au3")
        ;-------3DP Chip
    Case $chip
    $Download=InetGet("http://hotrotiemnet.com/wp-content/uploads/SU%20Ken/3DP_Chip.exe", @TempDir & "\3DP_Chip.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
        ShellExecute (@tempdir & "\3DP_Chip.exe")


    ;--------Info hardware
    Case $hwinfo
    $Download=InetGet("http://hotrotiemnet.com/wp-content/uploads/SU%20Ken/Speccy.exe", @TempDir & "\Speccy.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\Speccy.exe")
    ;--------Test Cpu & VGA
    Case $testcpu
    $Download=InetGet("http://hotrotiemnet.com/wp-content/uploads/SU%20Ken/test%20hw/ORTHOS.exe", @TempDir & "\ORTHOS.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
    $Download=InetGet("http://hotrotiemnet.com/wp-content/uploads/SU%20Ken/test%20hw/worker.dll", @TempDir & "\worker.dll", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\ORTHOS.exe")
    Case $GUI_EVENT_CLOSE
    If FileExists($TempDir & "\3DP_Chip.exe") Then
    FileDelete($TempDir & "\3DP_Chip.exe")
    EndIf
    If FileExists($TempDir & "\Speccy.exe") Then
    FileDelete($TempDir & "\Speccy.exe")
    EndIf
    If FileExists($TempDir & "\ORTHOS.exe") Then
    FileDelete($TempDir & "\ORTHOS.exe")
    EndIf
    If FileExists($TempDir & "\worker.dll") Then
    FileDelete($TempDir & "\worker.dll")
    EndIf
    Exit
    EndSwitch
    WEnd
     
    kamsamita1 thích bài này.
  2. kakanet

    kakanet Thành viên năng động
    • 43/45

    Tham gia ngày:
    24/2/16
    Bài viết:
    203
    Đã được thích:
    211
    Tui biết sơ vài thứ nên chỉ giúp bạn về GUI đk thui.

    code cũ
    Mã (AutoIt):
    $ListView1 = GUICtrlCreateListView("   Service                                                                                  |Status                           |               ", 8, 8, 460, 450, $LVS_NOSORTHEADER+$LVS_SINGLESEL,$LVS_EX_GRIDLINES )
     
    code mới
    Mã (AutoIt):
    $ListView1 = GUICtrlCreateListView("|   Service                                                                                  |Status                           |               ", 8, 8, 460, 450, $LVS_NOSORTHEADER + $LVS_SINGLESEL, $LVS_EX_GRIDLINES  + $LVS_EX_CHECKBOXES)
    Lưu ý cái | ở ngay sau GUICtrlCreateListView nhé.

    Những đoạn code GUICtrlCreateListViewItem($MyServices.........
    chuyển thành GUICtrlCreateListViewItem("|" & $MyServices.........
    hết nhé. Bấm vào Kiểm tra là nó ra check box theo service rùi nhé.

    Ở chỗ GUICtrlCreateListView(" Service |Status | ".....
    không nên để khoảng trống như vậy mà dùng hàm _GUICtrlListView_SetColumnWidth để định độ rộng cụ thể cho mỗi cột listview nhé. Tui biết chừng đó thui.
     
    kamsamita1 and Huân Hoàng like this.
  3. Huân Hoàng

    Huân Hoàng Administrator Thành viên BQT Administrator Super Moderator
    • 93/113

    Tham gia ngày:
    29/9/15
    Bài viết:
    642
    Đã được thích:
    1,181
    Sửa bài lần 2: Theo iêm thì nên cho hiển thị full list luôn, nhưng mình sẽ xếp lại danh sách, những service chắc chắn an toàn khi stop nó sẽ được xếp lên đầu, những service còn lại chắc là sẽ có những service thừa mà mình biết có thể stop được. Như vậy sẽ tuỳ biến cao hơn. Còn cách xếp thì tạo 1 mảng tên các service an toàn để stop rồi so sánh với list. Góp ý tí thế thôi ợ ;))
    -------------------------------------------------------------------
    Sửa bài lần 1: Đính chính lại comment bên dưới: Nhìn lại cái danh sách của thým thì hình như mấy cái service đó đều là service có thể tắt an toàn mà không ảnh hưởng đến máy phải không ? Vậy thì chắc chẳng cần full list rồi :p:p:p​
    ------------------------------------------------------------------
    Cái đoạn lấy danh sách services nhìn sao vất vả quá với lại không đầy đủ nữa, iêm code cái Func lấy list này, iêm XP chạy ổn, không biết mấy win khác thì sao, thým chạy thử xem được không :p:p​

    [​IMG]

    Mã (AutoIt):

    #include <array.au3>

    _ArrayDisplay(_GetList_Services())

    Func _GetList_Services($Retry_Timer = 2000, $Retry_Counter = 3)
        SplashTextOn('', 'Đang kiểm tra dữ liệu', 600, 90, -1, -1, 1, "Tahoma", 40)
        Local $_count = 0
        While Sleep(500)
            Local $iExitCode = Run(@ComSpec & ' /C sc  queryex type= service state= all', '', @SW_HIDE, 0x2)
            Local $sTimer = TimerInit(), $GetFullInfo
            While Sleep(10)
                If TimerDiff($sTimer) > $Retry_Timer Then ExitLoop SetError(999, 0, 1)
                $GetFullInfo &= StdoutRead($iExitCode)
                If @error Then ExitLoop
            WEnd
            If @error <> 999 Then
                ExitLoop
            Else
                $_count += 1
                ConsoleWrite(@CRLF & $_count)
                StdioClose($iExitCode)
                If $_count = $Retry_Counter Then Return (SplashOff() + SetError(2))
            EndIf
        WEnd
        StdioClose($iExitCode)
        SplashOff()
        $SERVICE_NAME = StringRegExp($GetFullInfo, '(?m)(?i)^\s*?(?:SERVICE_NAME)\s*?\:(.*?)$', 3)
        If @error Then Return SetError(3)
        $DISPLAY_NAME = StringRegExp($GetFullInfo, '(?m)(?i)^\s*?(?:DISPLAY_NAME)\s*?\:(.*?)$', 3)
        If @error Then Return SetError(3)
        $SERVICE_STATE = StringRegExp($GetFullInfo, '(?m)(?i)^\s*?(?:STATE)\s*?\:\s+?\d+?\s+?(.*?)$', 3)
        If @error Then Return SetError(3)
        Local $uSN = UBound($SERVICE_NAME), $uDN = UBound($DISPLAY_NAME), $uST = UBound($SERVICE_STATE)
        If $uSN <> $uDN Or $uSN <> $uST Then Return SetError(4)
        Local $aServiceList[$uSN][3]
        For $i = 0 To $uSN - 1
            $aServiceList[$i][0] = StringStripWS($SERVICE_NAME[$i], 3)
            $aServiceList[$i][1] = StringStripWS($DISPLAY_NAME[$i], 3)
            $aServiceList[$i][2] = StringStripWS($SERVICE_STATE[$i], 3)
        Next
        Return $aServiceList
    EndFunc
     
     
    Chỉnh sửa cuối: 28/2/16
    kamsamita1 thích bài này.
  4. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    Cảm ơn bạn. mình rất thích code này
     
    kamsamita1 thích bài này.
  5. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    @Huân Hoàng :
    Hiện nay mình đã cho chạy thử trên các win 7x32, win 7x64 và XP thì bình thường rồi.
     
    kamsamita1 thích bài này.
  6. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    @Huân Hoàng
    Nếu được thì bạn hỗ trợ giúp mình nhé. Cảm ơn bạn
     
    kamsamita1 thích bài này.
  7. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    @Huân Hoàng
    Hôm nay mình đã chỉnh sửa lại code vì có 1 số vấn đề phát sinh lỗi, bạn xem code lại giúp mình nha

    Mã (AutoIt):
    #include <ProgressConstants.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <MsgBoxConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <Constants.au3>
    #Include <WinAPI.au3>
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <StaticConstants.au3>
    #include <Process.au3>
    #include <ScrollBarConstants.au3>
    #include <GuiEdit.au3>
    #include <InetConstants.au3>
    #include <ListviewConstants.au3>

    Dim $adrivearray[100], $Var = False, $TempDir = @TempDir & "\"
    Dim $aRegKeys[33]
    Dim $drivearray[100]
    Dim $MyServices
    Dim $MyServicesList
    $Form1 = GUICreate("Optimize v2.2.0 by OSTEAM | Áp dụng cho Windows 7 & WindowsXP", 611, 497, 190, 125)
    $ListView1 = GUICtrlCreateListView(" | Service|Status | ", 8, 8, 460, 450, $LVS_NOSORTHEADER+$LVS_SINGLESEL,$LVS_EX_GRIDLINES )
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 25)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
    $opt = GUICtrlCreateButton("Optimize", 470, 68, 133, 59)
    $msconfig = GUICtrlCreateButton("Msconfig", 470, 131, 133, 59)
    $driver = GUICtrlCreateButton("Device Manager", 470, 193, 133, 59)
    $chkdsk = GUICtrlCreateButton("Check Disk", 470, 255, 133, 59)
    $chip = GUICtrlCreateButton("3D Chip", 470, 316, 133, 59)
    $hwinfo = GUICtrlCreateButton(" Hardware", 470, 377, 133, 59)
    $testcpu = GUICtrlCreateButton("TEST CPU - VGA ", 470, 437, 133, 59)
    $ktra = GUICtrlCreateButton("Check Services", 470, 7, 133, 59)
    $Progress1 = GUICtrlCreateProgress(8, 460, 460, 33)
    GUISetState(@SW_SHOW, $Form1)

          $MyServices = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
          $MyServicesList = $MyServices.ExecQuery("SELECT * FROM Win32_Service")

    While 1
          Switch GUIGetMsg()

    Case $ktra
         SplashTextOn("Thông báo", "Đang kiểm tra....", 400, 60, -1, -1, 1, "Tahoma", 24)
       ;----Windows Update---------------------
    $myServiceQuery = "Windows Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" &  $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
    ;----Computer Browser-----
    $myServiceQuery = "Computer Browser"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Bluetooth Support Service-----
    $myServiceQuery = "Bluetooth Support Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----DHCP Client-----
    $myServiceQuery = "DHCP Client"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Google Update Service (gupdate)-----
    $myServiceQuery = "Google Update Service (gupdate)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Google Update Service (gupdatem)-----
    $myServiceQuery = "Google Update Service (gupdatem)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Print Spooler-----
    $myServiceQuery = "Print Spooler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Skype Update-----
    $myServiceQuery = "Skype Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Disk Defragmenter-----
    $myServiceQuery = "Disk Defragmenter"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Desktop Window Manager Session Manager-----
    $myServiceQuery = "Desktop Window Manager Session Manager"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Task Scheduler-----
    $myServiceQuery = "Task Scheduler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
        ;----UPnP Device Host-----
    $myServiceQuery = "UPnP Device Host"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Defender-----
    $myServiceQuery = "Windows Defender"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Windows Firewall XP-----
    $myServiceQuery = "Windows Firewall/Internet Connection Sharing (ICS)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Firewall-----
    $myServiceQuery = "Windows Firewall"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Search-----
    $myServiceQuery = "Windows Search"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----WLAN AutoConfig-----
    $myServiceQuery = "WLAN AutoConfig"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Automatic Updates WinXP-----
    $myServiceQuery = "Automatic Updates"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Wireless Zero Configuration WinXP-----
    $myServiceQuery = "Wireless Zero Configuration"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Windows FireWall/Internet Connection Sharing(ICS) WinXP-----
    $myServiceQuery = "Windows FireWall/Internet Connection Sharing(ICS)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----QoS RSUP WinXP------
    $myServiceQuery = "QoS RSUP"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;----Superfetch------
    $myServiceQuery = "Superfetch"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------WinHTTP Web Proxy Auto-Discovery Service
         $myServiceQuery = "WinHTTP Web Proxy Auto-Discovery Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
             ;------System Restore Xp
         $myServiceQuery = "System Restore Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------Visual Effects
    $FW = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting")
    If $FW = 0 Then
       $FW = "Let Windows choose what's best for my computer "
    EndIf
    If $FW = 1 Then
       $FW = "Adjust for best appearance"
    EndIf
    If $FW = 2 Then
       $FW = "Adjust for best Performance "
    EndIf
    If $FW = 3 Then
       $FW = "Custom"
    EndIf
    GUICtrlCreateListViewItem("|" & "Visual Effects" & "|" & $FW & "|" & "System", $ListView1)

    ;---------PagingFiles--------
    $FW1 = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles")
    If $FW1 = "?:\pagefile.sys" Then
       $FW1 = "Automatically manage paging file size for all drivers"
    EndIf
    If $FW1 = "c:\pagefile.sys 4096 4096" Then
       $FW1 = "Custom Size :C:\4096 4096"
    EndIf
    If $FW1 = "c:\pagefile.sys 0 0" Then
       $FW1 = "System manged size"
    EndIf
    If $FW1 = "" Then
       $FW1 = "C:\None"
    EndIf
    GUICtrlCreateListViewItem("|" & "Paging Files" & "|" & $FW1 & "|" & "System", $ListView1)

    ;---------Automatically restart----
    $FW2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "AutoReboot")
    If $FW2 = 0 Then
       $FW2 = "Disable"
    EndIf
    If $FW2 = 1 Then
       $FW2 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("|" & "Automatically restart" & "|" & $FW2 & "|" & "System", $ListView1)
    ;---------Write debugging infomation----
    $FW4 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "CrashDumpEnabled")
    If $FW4 = 0 Then
       $FW4 = "(None)"
    EndIf
    If $FW4 = 3 Then
       $FW4 = "Small memory dump (256KB)"
    EndIf
    If $FW4 = 2 Then
       $FW4 = "Kernel memory dump"
    EndIf
    GUICtrlCreateListViewItem("|" & "Write debugging infomation" & "|" & $FW4 & "|" & "System", $ListView1)
    ;---------Write an event to the system log----
    $FW5 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "LogEvent")
    If @OSArch = "X64" Then
       EndIf
    If $FW5 = 0 Then
       $FW5 = "Disable"
    EndIf
    If $FW5 = 1 Then
       $FW5 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("|" & "Write an event to the system log" & "|" & $FW5 & "|" & "System", $ListView1)
    ;---------ComputerRestore----
    If @OSVersion = "WIN_7" Then
    $FW3 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval")

    If @OSArch = "X64" Then
       EndIf
    If $FW3 = 0 Then
       $FW3 = "Disable"
    EndIf
    If $FW3 = 1 Then
       $FW3 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("|" & "System Restore" & "|" & $FW3 & "|" & "System", $ListView1)
    EndIf
    ;---------ComputerRestore XP----
    If @OSVersion = "WIN_XP" Then
    $FW6 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore", "DisableSR")
    If $FW6 = 0 Then
       $FW6 = "Disable"
    EndIf
    If $FW6 = 1 Then
       $FW6 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("|" & "System Restore" & "|" & $FW6 & "|" & "System", $ListView1)
    EndIf
    SplashOff()
           ;--------------------
        Case $opt
           SplashTextOn("Thông báo", "Đang Optimize....", 400, 60, -1, -1, 1, "Tahoma", 24)
      Local $sService,$sCMD,$xCMD,$vCMD,$sListService=StringSplit("wuauserv|AMD External Events Utility|AMD FUEL Service|amdacpusrsvc|NVSvc|FontCache3.0.0.0|WPFFontCache_v0400|NvNetworkService|GfExperienceService|NvStreamSvc|WajaIntEn Monitor|PnkBstrA|AMD External Events Utility|odserv|idsvc|MozillaMaintenance|Stereo Service|nvsvc|igfxCUIService1.0.0.0|ICCS|cphs|LMS|jhi_service|Intel(R) Capability Licensing Service TCP IP Interface|Intel(R) Capability Licensing Service Interface|WinHttpAutoProxySvc|SysMain|MpsSvc|WSearch|WinDefend|gupdate|gupdatem|UxSms|BstHdUpdaterSvc|defragsvc|Browser|upnphost|Schedule|TabletInputService|Wlansvc|bthserv|srservice|uxsms|WZCSVC|SharedAccess","|")
    For $i=1 to UBound($sListService)-1
        $sService=$sListService[$i]
          GUICtrlSetData($Progress1,$i*3)
        ConsoleWrite(">! Stoping service: "&$sService&@CRLF)
        RunWait('"'&@ComSpec&'" /c sc config "'&$sService&'" start= Disabled',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc config Dhcp start= auto',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net start Dhcp',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set AutoReboot = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set WriteToSystemLog = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set DebugInfoType = 0',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c schtasks /delete /tn * /f',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c bcdedit /timeout 0',@SystemDir,@SW_HIDE)
        ConsoleWrite($sService&" disabled."&@CRLF)

    Next


    ;-----------------------------VisualEffects
    Local $sRegKey = "\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
    If @OSArch = "X64" Then
        $sRegKey = "HKCU64" & $sRegKey
    Else
        $sRegKey = "HKCU" & $sRegKey
    EndIf
    RegWrite($sRegKey, "VisualFXSetting", "REG_DWORD", "2")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey
    EndIf
    RegWrite($sRegKey, "RPSessionInterval", "REG_DWORD", "0")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegDelete($sRegKey)

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegWrite($sRegKey)

    ;-----------------------------PagingFiles
    Local $sRegKey = "\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "PagingFiles", "REG_MULTI_SZ", "C:\pagefile.sys 4096 4096")

    ;-----------------------------UAC
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "EnableLUA", "REG_DWORD", "0")

    ;-----------------------------USB Root Hub Power Management
    Local $sRegKey = "\HKLM\SYSTEM\CurrentControlSet\Services\USB"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "DisableSelectiveSuspend", "REG_DWORD", "1")

    ;-----------------------------Task Scheduler
    Local $sRegKey = "\SYSTEM\CurrentControlSet\services\Schedule"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "Start", "REG_DWORD", "3")

    ;-----------------------------Msconfig

        $aRegKeys[0] = "IMJPMIG"
        $aRegKeys[1] = "CocCoc Update"
        $aRegKeys[2] = "Intel(R) Common User Interface"
        $aRegKeys[3] = "Java Platform SE Auto Updater"
        $aRegKeys[4] = "IgfxTray"
        $aRegKeys[5] = "HotKeysCmds"
        $aRegKeys[6] = "Vmware User process"
        $aRegKeys[7] = "ImScInst"
        $aRegKeys[8] = "hkcmd"
        $aRegKeys[9] = "igfxpers"
        $aRegKeys[10] = "StartCCC"
        $aRegKeys[11] = "USB3MON"
        $aRegKeys[12] = "CuHanhPlay"
        $aRegKeys[13] = "SynTPEnh"
        $aRegKeys[14] = "Quicktime Task"
        $aRegKeys[15] = "iTunesHelper"
        $aRegKeys[16] = "NvBackend"
        $aRegKeys[17] = "NvMctray"
        $aRegKeys[18] = "Persistence"
        $aRegKeys[19] = "SunJavaUpdateSched"
        $aRegKeys[20] = "ctfmon.exe"
        $aRegKeys[21] = "NvCpl"
        $aRegKeys[22] = "TINTSETP"
        $aRegKeys[23] = "jusched"
        $aRegKeys[24] = "CocCoc"
        $aRegKeys[25] = "IMEKRMIG"
        $aRegKeys[26] = "CCleaner Monitoring"
        $aRegKeys[27] = "Google Update"
        $aRegKeys[28] = "ShadowPlay"
        $aRegKeys[29] = "AppEx Accelerator UI"
        $aRegKeys[30] = "StartCN"
        $aRegKeys[31] = "DFX"
        $aRegKeys[32] = "Raptr"


        ; Loop to delete startup registry keys
        #requireAdmin
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
             ; Loop to delete startup registry keys
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
         SplashOff()
    ;-----------------------------MsgBox
    MsgBox($MB_SYSTEMMODAL, "Hoàn thành", "Hoàn thành !")
    ;---------------------------
    Case $msconfig
    #requireadmin
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
    ShellExecute('msconfig.exe', -4) ; << 4 = which tab to display
    DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)
    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "MSConfig") ; << stops the message after reboot
    ;--------------- Device Manager----------
    Case $driver
        Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE)
    ;----------------Check Disk-------------
    Case $chkdsk
        Run(@ComSpec & " /c " & 'cmd.exe', "",  @SW_SHOW)
        ;-------3DP Chip
    Case $chip
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/3DPChip.exe", @TempDir & "\3DPChip.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\3DPChip.exe")
        ;--------Info hardware
    Case $hwinfo
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/Speccy.exe", @TempDir & "\Speccy.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\Speccy.exe")
    ;--------Test Cpu & VGA
    Case $testcpu
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/ORTHOS.exe", @TempDir & "\ORTHOS.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
    Sleep (250)
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/worker.dll", @TempDir & "\worker.dll", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(500)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\ORTHOS.exe")
    Case $GUI_EVENT_CLOSE
    If FileExists($TempDir & "CheckDisk.exe") Then
    FileDelete($TempDir & "CheckDisk.exe")
    EndIf
    If FileExists($TempDir & "3DP_Chip.exe") Then
    FileDelete($TempDir & "3DP_Chip.exe")
    EndIf
    If FileExists($TempDir & "Speccy.exe") Then
    FileDelete($TempDir & "Speccy.exe")
    EndIf
    If FileExists($TempDir & "ORTHOS.exe") Then
    FileDelete($TempDir & "ORTHOS.exe")
    EndIf
    If FileExists($TempDir & "worker.dll") Then
    FileDelete($TempDir & "worker.dll")
    EndIf
    Exit
    EndSwitch
    WEnd
     
    kamsamita1 thích bài này.
  8. Huân Hoàng

    Huân Hoàng Administrator Thành viên BQT Administrator Super Moderator
    • 93/113

    Tham gia ngày:
    29/9/15
    Bài viết:
    642
    Đã được thích:
    1,181
    Chưa hiện ra checkbox là do chưa thêm ExStyle $LVS_EX_CHECKBOXES của Listview, giờ chương trình này còn vấn đề gì nữa không ? Cách enable/disable các service đã check phải không ? :p
     
    kamsamita1 thích bài này.
  9. Huân Hoàng

    Huân Hoàng Administrator Thành viên BQT Administrator Super Moderator
    • 93/113

    Tham gia ngày:
    29/9/15
    Bài viết:
    642
    Đã được thích:
    1,181
    Mình đã chỉnh lại một tí cho code của bạn:
    - Để các Button cách đều thì không nên dùng số cụ thể mà dùng phép + và * theo số Button.
    - Các service thay vì liệt kê ra như vậy sẽ không hay và khó kiểm tra, ví dụ trong code có cái đoạn "Windows Firewall/Internet Connection Sharing (ICS)" bị lặp 2 lần, nên mình sẽ cho tất cả chúng vô mảng để chạy, nhìn tường minh và gọn hơn rất nhiều.
    - Để check được các Item của LV thì phải đặt biến cho chúng nên mình tạo một array Item, nếu không có lỗi thì cho cái mảng này tăng 1 và set cho Item LV.
    - Để check state của Item LV thì phải dùng GuiCtrlRead ở chế độ advanced = 1 và dùng BitAnd để check State.
    - Còn để En/Disable Service thì mình không chắc nên sẽ để đó :p:p

    Cụ thể:

    Mã (AutoIt):
    #include <ProgressConstants.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <MsgBoxConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <StaticConstants.au3>
    #include <Process.au3>
    #include <ScrollBarConstants.au3>
    #include <GuiEdit.au3>
    #include <InetConstants.au3>
    #include <ListviewConstants.au3>

    Dim $adrivearray[100], $Var = False, $TempDir = @TempDir & "\"
    Dim $aRegKeys[33]
    Dim $drivearray[100]
    Dim $MyServices
    Dim $MyServicesList
    $Form1 = GUICreate("Optimize v2.2.0 by OSTEAM | Áp dụng cho Windows 7 & WindowsXP", 611, 540, 190, 125)
    $ListView1 = GUICtrlCreateListView(" | Service|Status | ", 8, 8, 460, 450, $LVS_NOSORTHEADER + $LVS_SINGLESEL, $LVS_EX_GRIDLINES + $LVS_EX_CHECKBOXES)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 25)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
    $opt = GUICtrlCreateButton("Optimize", 470, 68, 133, 60)
    $msconfig = GUICtrlCreateButton("Msconfig", 470, 68 + 61 * 1, 133, 60)
    $driver = GUICtrlCreateButton("Device Manager", 470, 68 + 61 * 2, 133, 60)
    $chkdsk = GUICtrlCreateButton("Check Disk", 470, 68 + 61 * 3, 133, 60)
    $chip = GUICtrlCreateButton("3D Chip", 470, 68 + 61 * 4, 133, 60)
    $hwinfo = GUICtrlCreateButton(" Hardware", 470, 68 + 61 * 5, 133, 60)
    $testcpu = GUICtrlCreateButton("TEST CPU - VGA ", 470, 68 + 61 * 6, 133, 60)
    $ktra = GUICtrlCreateButton("Check Services", 470, 7, 133, 60)
    $Progress1 = GUICtrlCreateProgress(8, 460, 460, 33)

    $buttonEnable = GUICtrlCreateButton("ENABLE", 8, 540 - 40, 229, 30)
    $buttonDisable = GUICtrlCreateButton("DISABLE", 239, 540 - 40, 229, 30)
    GUISetState(@SW_SHOW, $Form1)

    Global $MyServices = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
    Global $MyServicesList = $MyServices.ExecQuery("SELECT * FROM Win32_Service")
    Global $aMyServiceQuery[] = ['Windows Update', 'Computer Browser', 'Bluetooth Support Service', 'DHCP Client', 'Google Update Service (gupdate)', 'Google Update Service (gupdatem)', 'Print Spooler', 'Skype Update', 'Disk Defragmenter', 'Desktop Window Manager Session Manager', 'Task Scheduler', 'UPnP Device Host', 'Windows Defender', 'Windows Firewall/Internet Connection Sharing (ICS)', 'Windows Firewall', 'Windows Search', 'WLAN AutoConfig', 'Automatic Updates', 'Wireless Zero Configuration', 'QoS RSUP', 'Superfetch', 'WinHTTP Web Proxy Auto-Discovery Service', 'System Restore Service']
    Global $ItemListview[0]

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg

            Case $buttonEnable, $buttonDisable
                $soluong_Item = UBound($ItemListview)
                If $soluong_Item > 0 Then
                    For $i = 0 To $soluong_Item - 1
                        $checked = BitAND(GUICtrlRead($ItemListview[$i], 1), 1) ;checkbox của Listview phải dùng GUICtrlRead chế độ 1 và BitAnd để lấy state.
                        If $checked = 1 Then
                            ConsoleWrite(@CRLF & 'Item ' & $i & ' is checked') ;kiểm tra chương trình
                            If $nMsg = $buttonEnable Then
                                ; Thêm code enable service ở đây
                            ElseIf $nMsg = $buttonDisable Then
                                ; Thêm code disable service ở đây
                            EndIf
                            ; Thêm code set % cho Progress ở đây
                        EndIf
                    Next
                EndIf

            Case $ktra
                SplashTextOn("Thông báo", "Đang kiểm tra....", 400, 60, -1, -1, 1, "Tahoma", 24)
                Local $counter_service = 0


                For $i = 0 To UBound($aMyServiceQuery) - 1
                    For $MyServices In $MyServicesList
                        If $MyServices.DisplayName = $aMyServiceQuery[$i] Then
                            $counter_service += 1
                            ReDim $ItemListview[$counter_service]
                            $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & $MyServices.DisplayName & "|" & $MyServices.State & "|Services", $ListView1)
                        EndIf
                    Next
                Next

                ;------Visual Effects
                $FW = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting")
                Switch $FW
                    Case 0
                        $FW = "Let Windows choose what's best for my computer "
                    Case 1
                        $FW = "Adjust for best appearance"
                    Case 2
                        $FW = "Adjust for best Performance "
                    Case 3
                        $FW = "Custom"
                EndSwitch
                If Not @error Then
                    $counter_service += 1
                    ReDim $ItemListview[$counter_service]
                    $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "Visual Effects" & "|" & $FW & "|" & "System", $ListView1)
                EndIf

                ;---------PagingFiles--------
                $FW1 = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles")
                Switch $FW1
                    Case "?:\pagefile.sys"
                        $FW1 = "Automatically manage paging file size for all drivers"
                    Case "c:\pagefile.sys 4096 4096"
                        $FW1 = "Custom Size :C:\4096 4096"
                    Case "c:\pagefile.sys 0 0"
                        $FW1 = "System manged size"
                    Case ""
                        $FW1 = "C:\None"
                EndSwitch
                If Not @error Then
                    $counter_service += 1
                    ReDim $ItemListview[$counter_service]
                    $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "Paging Files" & "|" & $FW1 & "|" & "System", $ListView1)
                EndIf

                ;---------Automatically restart----
                $FW2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "AutoReboot")
                Switch $FW2
                    Case 0
                        $FW2 = "Disable"
                    Case 1
                        $FW2 = "Enable"
                EndSwitch
                If Not @error Then
                    $counter_service += 1
                    ReDim $ItemListview[$counter_service]
                    $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "Automatically restart" & "|" & $FW2 & "|" & "System", $ListView1)
                EndIf

                ;---------Write debugging infomation----
                $FW4 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "CrashDumpEnabled")
                Switch $FW4
                    Case 0
                        $FW4 = "(None)"
                    Case 3
                        $FW4 = "Small memory dump (256KB)"
                    Case 2
                        $FW4 = "Kernel memory dump"
                EndSwitch
                If Not @error Then
                    $counter_service += 1
                    ReDim $ItemListview[$counter_service]
                    $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "Write debugging infomation" & "|" & $FW4 & "|" & "System", $ListView1)
                EndIf

                ;---------Write an event to the system log----
                If @OSArch = "X64" Then
                    ;???????
                EndIf
                $FW5 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "LogEvent")
                Switch $FW5
                    Case 0
                        $FW5 = "Disable"
                    Case 1
                        $FW5 = "Enable"
                EndSwitch
                If Not @error Then
                    $counter_service += 1
                    ReDim $ItemListview[$counter_service]
                    $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "Write an event to the system log" & "|" & $FW5 & "|" & "System", $ListView1)
                EndIf

                ;---------ComputerRestore----
                If @OSVersion = "WIN_7" Then
                    If @OSArch = "X64" Then
                        ;???????
                    EndIf
                    $FW3 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval")
                    Switch $FW3
                        Case 0
                            $FW3 = "Disable"
                        Case 1
                            $FW3 = "Enable"
                    EndSwitch
                    If Not @error Then
                        $counter_service += 1
                        ReDim $ItemListview[$counter_service]
                        $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "System Restore" & "|" & $FW3 & "|" & "System", $ListView1)
                    EndIf
                EndIf

                ;---------ComputerRestore XP----
                If @OSVersion = "WIN_XP" Then
                    $FW6 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore", "DisableSR")
                    Switch $FW6
                        Case 0
                            $FW6 = "Disable"
                        Case 1
                            $FW6 = "Enable"
                    EndSwitch
                    If Not @error Then
                        $counter_service += 1
                        ReDim $ItemListview[$counter_service]
                        $ItemListview[$counter_service - 1] = GUICtrlCreateListViewItem("|" & "System Restore" & "|" & $FW6 & "|" & "System", $ListView1)
                    EndIf
                EndIf
                SplashOff()
                ;--------------------
                ConsoleWrite(@CRLF & 'The quantity of Items: ' & UBound($ItemListview))



            Case $opt
                SplashTextOn("Thông báo", "Đang Optimize....", 400, 60, -1, -1, 1, "Tahoma", 24)
                Local $sService, $sCMD, $xCMD, $vCMD, $sListService = StringSplit("wuauserv|AMD External Events Utility|AMD FUEL Service|amdacpusrsvc|NVSvc|FontCache3.0.0.0|WPFFontCache_v0400|NvNetworkService|GfExperienceService|NvStreamSvc|WajaIntEn Monitor|PnkBstrA|AMD External Events Utility|odserv|idsvc|MozillaMaintenance|Stereo Service|nvsvc|igfxCUIService1.0.0.0|ICCS|cphs|LMS|jhi_service|Intel(R) Capability Licensing Service TCP IP Interface|Intel(R) Capability Licensing Service Interface|WinHttpAutoProxySvc|SysMain|MpsSvc|WSearch|WinDefend|gupdate|gupdatem|UxSms|BstHdUpdaterSvc|defragsvc|Browser|upnphost|Schedule|TabletInputService|Wlansvc|bthserv|srservice|uxsms|WZCSVC|SharedAccess", "|")
                For $i = 1 To UBound($sListService) - 1
                    $sService = $sListService[$i]
                    GUICtrlSetData($Progress1, $i * 3)
                    ConsoleWrite(">! Stoping service: " & $sService & @CRLF)
                    RunWait('"' & @ComSpec & '" /c sc config "' & $sService & '" start= Disabled', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c sc stop "' & $sService & '"', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c net stop "' & $sService & '"', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c sc config Dhcp start= auto', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c net start Dhcp', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c wmic recoveros set AutoReboot = False', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c wmic recoveros set WriteToSystemLog = False', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c wmic recoveros set DebugInfoType = 0', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c schtasks /delete /tn * /f', @SystemDir, @SW_HIDE)
                    RunWait('"' & @ComSpec & '" /c bcdedit /timeout 0', @SystemDir, @SW_HIDE)
                    ConsoleWrite($sService & " disabled." & @CRLF)

                Next


                ;-----------------------------VisualEffects
                Local $sRegKey = "\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
                If @OSArch = "X64" Then
                    $sRegKey = "HKCU64" & $sRegKey
                Else
                    $sRegKey = "HKCU" & $sRegKey
                EndIf
                RegWrite($sRegKey, "VisualFXSetting", "REG_DWORD", "2")

                ;-----------------------------ComputerRestore
                Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey
                EndIf
                RegWrite($sRegKey, "RPSessionInterval", "REG_DWORD", "0")

                ;-----------------------------ComputerRestore
                Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegDelete($sRegKey)

                ;-----------------------------ComputerRestore
                Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegWrite($sRegKey)

                ;-----------------------------PagingFiles
                Local $sRegKey = "\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegWrite($sRegKey, "PagingFiles", "REG_MULTI_SZ", "C:\pagefile.sys 4096 4096")

                ;-----------------------------UAC
                Local $sRegKey = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegWrite($sRegKey, "EnableLUA", "REG_DWORD", "0")

                ;-----------------------------USB Root Hub Power Management
                Local $sRegKey = "\HKLM\SYSTEM\CurrentControlSet\Services\USB"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegWrite($sRegKey, "DisableSelectiveSuspend", "REG_DWORD", "1")

                ;-----------------------------Task Scheduler
                Local $sRegKey = "\SYSTEM\CurrentControlSet\services\Schedule"
                If @OSArch = "X64" Then
                    $sRegKey = "HKLM64" & $sRegKey
                Else
                    $sRegKey = "HKLM" & $sRegKey

                EndIf
                RegWrite($sRegKey, "Start", "REG_DWORD", "3")

                ;-----------------------------Msconfig

                $aRegKeys[0] = "IMJPMIG"
                $aRegKeys[1] = "CocCoc Update"
                $aRegKeys[2] = "Intel(R) Common User Interface"
                $aRegKeys[3] = "Java Platform SE Auto Updater"
                $aRegKeys[4] = "IgfxTray"
                $aRegKeys[5] = "HotKeysCmds"
                $aRegKeys[6] = "Vmware User process"
                $aRegKeys[7] = "ImScInst"
                $aRegKeys[8] = "hkcmd"
                $aRegKeys[9] = "igfxpers"
                $aRegKeys[10] = "StartCCC"
                $aRegKeys[11] = "USB3MON"
                $aRegKeys[12] = "CuHanhPlay"
                $aRegKeys[13] = "SynTPEnh"
                $aRegKeys[14] = "Quicktime Task"
                $aRegKeys[15] = "iTunesHelper"
                $aRegKeys[16] = "NvBackend"
                $aRegKeys[17] = "NvMctray"
                $aRegKeys[18] = "Persistence"
                $aRegKeys[19] = "SunJavaUpdateSched"
                $aRegKeys[20] = "ctfmon.exe"
                $aRegKeys[21] = "NvCpl"
                $aRegKeys[22] = "TINTSETP"
                $aRegKeys[23] = "jusched"
                $aRegKeys[24] = "CocCoc"
                $aRegKeys[25] = "IMEKRMIG"
                $aRegKeys[26] = "CCleaner Monitoring"
                $aRegKeys[27] = "Google Update"
                $aRegKeys[28] = "ShadowPlay"
                $aRegKeys[29] = "AppEx Accelerator UI"
                $aRegKeys[30] = "StartCN"
                $aRegKeys[31] = "DFX"
                $aRegKeys[32] = "Raptr"


                ; Loop to delete startup registry keys
                #RequireAdmin
                For $g = 0 To UBound($aRegKeys) - 1
                    RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
                    RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
                    RegRead("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
                    If @error <> 0 Then
                        ; do nothing
                    Else
                        For $r = 0 To UBound($aRegKeys) - 1
                            RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                            RegDelete("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                            RegDelete("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                            Sleep(100)
                        Next
                    EndIf
                Next
                ; Loop to delete startup registry keys
                For $g = 0 To UBound($aRegKeys) - 1
                    RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
                    RegRead("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
                    If @error <> 0 Then
                        ; do nothing
                    Else
                        For $r = 0 To UBound($aRegKeys) - 1
                            RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                            RegDelete("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                            Sleep(100)
                        Next
                    EndIf
                Next
                SplashOff()
                ;-----------------------------MsgBox
                MsgBox($MB_SYSTEMMODAL, "Hoàn thành", "Hoàn thành !")
                ;---------------------------
            Case $msconfig
                #RequireAdmin
                DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
                ShellExecute('msconfig.exe', -4) ; << 4 = which tab to display
                DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)
                RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "MSConfig") ; << stops the message after reboot
                ;--------------- Device Manager----------
            Case $driver
                Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE)
                ;----------------Check Disk-------------
            Case $chkdsk
                Run(@ComSpec & " /c " & 'cmd.exe', "", @SW_SHOW)
                ;-------3DP Chip
            Case $chip
                $Download = InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/3DPChip.exe", @TempDir & "\3DPChip.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(250)
                Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
                ShellExecute(@TempDir & "\3DPChip.exe")
                ;--------Info hardware
            Case $hwinfo
                $Download = InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/Speccy.exe", @TempDir & "\Speccy.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(250)
                Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
                ShellExecute(@TempDir & "\Speccy.exe")
                ;--------Test Cpu & VGA
            Case $testcpu
                $Download = InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/ORTHOS.exe", @TempDir & "\ORTHOS.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Sleep(250)
                $Download = InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/worker.dll", @TempDir & "\worker.dll", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(500)
                Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
                ShellExecute(@TempDir & "\ORTHOS.exe")
            Case $GUI_EVENT_CLOSE
                If FileExists($TempDir & "CheckDisk.exe") Then
                    FileDelete($TempDir & "CheckDisk.exe")
                EndIf
                If FileExists($TempDir & "3DP_Chip.exe") Then
                    FileDelete($TempDir & "3DP_Chip.exe")
                EndIf
                If FileExists($TempDir & "Speccy.exe") Then
                    FileDelete($TempDir & "Speccy.exe")
                EndIf
                If FileExists($TempDir & "ORTHOS.exe") Then
                    FileDelete($TempDir & "ORTHOS.exe")
                EndIf
                If FileExists($TempDir & "worker.dll") Then
                    FileDelete($TempDir & "worker.dll")
                EndIf
                Exit
        EndSwitch
    WEnd
     
     
    kamsamita1 thích bài này.
  10. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    Mã (AutoIt):
    #include <ProgressConstants.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <MsgBoxConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <Constants.au3>
    #Include <WinAPI.au3>
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <StaticConstants.au3>
    #include <ScrollBarConstants.au3>
    #include <GuiEdit.au3>
    #include <InetConstants.au3>
    #include <ListviewConstants.au3>

    Dim $adrivearray[100], $Var = False, $TempDir = @TempDir & "\"
    Dim $aRegKeys[33]
    Dim $drivearray[100]
    Dim $MyServices
    Dim $MyServicesList
    $Form1 = GUICreate("Optimize v2.2.0 by OS TECHNICAL | Áp dụng cho Windows 7 & WindowsXP", 611, 497, 190, 125)
    $ListView1 = GUICtrlCreateListView("Service|Status | ", 8, 8, 460, 480, $LVS_NOSORTHEADER+$LVS_SINGLESEL,$LVS_EX_GRIDLINES )
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
    $opt = GUICtrlCreateButton("Optimize", 470, 68, 133, 59)
    $msconfig = GUICtrlCreateButton("Msconfig", 470, 131, 133, 59)
    $driver = GUICtrlCreateButton("Device Manager", 470, 193, 133, 59)
    $chkdsk = GUICtrlCreateButton("Check Disk", 470, 255, 133, 59)
    $chip = GUICtrlCreateButton("3D Chip", 470, 316, 133, 59)
    $hwinfo = GUICtrlCreateButton(" Hardware", 470, 377, 133, 59)
    $ktra = GUICtrlCreateButton("Check Services", 470, 7, 133, 59)
    GUISetState(@SW_SHOW, $Form1)

          $MyServices = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
          $MyServicesList = $MyServices.ExecQuery("SELECT * FROM Win32_Service")

    While 1
          Switch GUIGetMsg()

    Case $ktra
         SplashTextOn("Thông báo", "Đang kiểm tra....", 400, 55, -1, -1, 1, "Times New Roman", 24)
       ;----Windows Update---------------------
    $myServiceQuery = "Windows Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
    ;----Computer Browser-----
    $myServiceQuery = "Computer Browser"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Bluetooth Support Service-----
    $myServiceQuery = "Bluetooth Support Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----DHCP Client-----
    $myServiceQuery = "DHCP Client"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Google Update Service (gupdate)-----
    $myServiceQuery = "Google Update Service (gupdate)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Google Update Service (gupdatem)-----
    $myServiceQuery = "Google Update Service (gupdatem)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Print Spooler-----
    $myServiceQuery = "Print Spooler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Skype Update-----
    $myServiceQuery = "Skype Update"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Disk Defragmenter-----
    $myServiceQuery = "Disk Defragmenter"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Desktop Window Manager Session Manager-----
    $myServiceQuery = "Desktop Window Manager Session Manager"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Task Scheduler-----
    $myServiceQuery = "Task Scheduler"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
        ;----UPnP Device Host-----
    $myServiceQuery = "UPnP Device Host"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Defender-----
    $myServiceQuery = "Windows Defender"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
               ;----Windows Firewall XP-----
    $myServiceQuery = "Windows Firewall/Internet Connection Sharing (ICS)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Firewall-----
    $myServiceQuery = "Windows Firewall"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
          ;----Windows Search-----
    $myServiceQuery = "Windows Search"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----WLAN AutoConfig-----
    $myServiceQuery = "WLAN AutoConfig"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Automatic Updates WinXP-----
    $myServiceQuery = "Automatic Updates"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Wireless Zero Configuration WinXP-----
    $myServiceQuery = "Wireless Zero Configuration"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----Windows FireWall/Internet Connection Sharing(ICS) WinXP-----
    $myServiceQuery = "Windows FireWall/Internet Connection Sharing(ICS)"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;----QoS RSUP WinXP------
    $myServiceQuery = "QoS RSUP"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;----Superfetch------
    $myServiceQuery = "Superfetch"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------WinHTTP Web Proxy Auto-Discovery Service
         $myServiceQuery = "WinHTTP Web Proxy Auto-Discovery Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
              ;------System Restore Xp
         $myServiceQuery = "System Restore Service"
        For $MyServices in $MyServicesList
            If $MyServices.DisplayName = $myServiceQuery Then
               GUICtrlCreateListViewItem($MyServices.DisplayName & "|" & $MyServices.State & "|" & "Services", $ListView1)
            EndIf
         Next
         ;------Visual Effects
    $FW = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting")
    If $FW = 0 Then
       $FW = "Let Windows choose what's best for my computer "
    EndIf
    If $FW = 1 Then
       $FW = "Adjust for best appearance"
    EndIf
    If $FW = 2 Then
       $FW = "Adjust for best Performance "
    EndIf
    If $FW = 3 Then
       $FW = "Custom"
    EndIf
    GUICtrlCreateListViewItem("Visual Effects" & "|" & $FW & "|" & "System", $ListView1)

    ;---------PagingFiles--------
    $FW1 = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles")
    If $FW1 = "?:\pagefile.sys" Then
       $FW1 = "Automatically manage paging file size for all drivers"
    EndIf
    If $FW1 = "c:\pagefile.sys 4096 4096" Then
       $FW1 = "Custom Size :C:\4096 4096"
    EndIf
    If $FW1 = "c:\pagefile.sys 0 0" Then
       $FW1 = "System manged size"
    EndIf
    If $FW1 = "" Then
       $FW1 = "C:\None"
    EndIf
    GUICtrlCreateListViewItem("Paging Files" & "|" & $FW1 & "|" & "System", $ListView1)

    ;---------Automatically restart----
    $FW2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "AutoReboot")
    If $FW2 = 0 Then
       $FW2 = "Disable"
    EndIf
    If $FW2 = 1 Then
       $FW2 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("Automatically restart" & "|" & $FW2 & "|" & "System", $ListView1)
    ;---------Write debugging infomation----
    $FW4 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "CrashDumpEnabled")
    If $FW4 = 0 Then
       $FW4 = "(None)"
    EndIf
    If $FW4 = 3 Then
       $FW4 = "Small memory dump (256KB)"
    EndIf
    If $FW4 = 2 Then
       $FW4 = "Kernel memory dump"
    EndIf
    GUICtrlCreateListViewItem("Write debugging infomation" & "|" & $FW4 & "|" & "System", $ListView1)
    ;---------Write an event to the system log----
    $FW5 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl", "LogEvent")
    If @OSArch = "X64" Then
       EndIf
    If $FW5 = 0 Then
       $FW5 = "Disable"
    EndIf
    If $FW5 = 1 Then
       $FW5 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("Write an event to the system log" & "|" & $FW5 & "|" & "System", $ListView1)
    ;---------ComputerRestore----
    If @OSVersion = "WIN_7" Then
    $FW3 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval")

    If @OSArch = "X64" Then
       EndIf
    If $FW3 = 0 Then
       $FW3 = "Disable"
    EndIf
    If $FW3 = 1 Then
       $FW3 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("System Restore" & "|" & $FW3 & "|" & "System", $ListView1)
    EndIf
    ;---------ComputerRestore XP----
    If @OSVersion = "WIN_XP" Then
    $FW6 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore", "DisableSR")
    If $FW6 = 0 Then
       $FW6 = "Disable"
    EndIf
    If $FW6 = 1 Then
       $FW6 = "Enable"
    EndIf
    GUICtrlCreateListViewItem("System Restore" & "|" & $FW6 & "|" & "System", $ListView1)
    EndIf
    SplashOff()
           ;--------------------
        Case $opt
           SplashTextOn("Thông báo", "Đang Optimize....", 400, 60, -1, -1, 1, "Times New Roman", 24)
      Local $sService,$sCMD,$xCMD,$vCMD,$sListService=StringSplit("wuauserv|AMD External Events Utility|AMD FUEL Service|amdacpusrsvc|NVSvc|FontCache3.0.0.0|WPFFontCache_v0400|NvNetworkService|GfExperienceService|NvStreamSvc|WajaIntEn Monitor|PnkBstrA|AMD External Events Utility|odserv|idsvc|MozillaMaintenance|Stereo Service|nvsvc|igfxCUIService1.0.0.0|ICCS|cphs|LMS|jhi_service|Intel(R) Capability Licensing Service TCP IP Interface|Intel(R) Capability Licensing Service Interface|WinHttpAutoProxySvc|SysMain|MpsSvc|WSearch|WinDefend|gupdate|gupdatem|UxSms|BstHdUpdaterSvc|defragsvc|Browser|upnphost|Schedule|TabletInputService|Wlansvc|bthserv|srservice|uxsms|WZCSVC|SharedAccess","|")
    For $i=1 to UBound($sListService)-1
        $sService=$sListService[$i]
        ConsoleWrite(">! Stoping service: "&$sService&@CRLF)
        RunWait('"'&@ComSpec&'" /c sc config "'&$sService&'" start= Disabled',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net stop "'&$sService&'"',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c sc config Dhcp start= auto',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c net start Dhcp',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set AutoReboot = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set WriteToSystemLog = False',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c wmic recoveros set DebugInfoType = 0',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c schtasks /delete /tn * /f',@SystemDir,@SW_HIDE)
        RunWait('"'&@ComSpec&'" /c bcdedit /timeout 0',@SystemDir,@SW_HIDE)
        ConsoleWrite($sService&" disabled."&@CRLF)

    Next


    ;-----------------------------VisualEffects
    Local $sRegKey = "\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
    If @OSArch = "X64" Then
        $sRegKey = "HKCU64" & $sRegKey
    Else
        $sRegKey = "HKCU" & $sRegKey
    EndIf
    RegWrite($sRegKey, "VisualFXSetting", "REG_DWORD", "2")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey
    EndIf
    RegWrite($sRegKey, "RPSessionInterval", "REG_DWORD", "0")

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegDelete($sRegKey)

    ;-----------------------------ComputerRestore
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

        EndIf
    RegWrite($sRegKey)

    ;-----------------------------PagingFiles
    Local $sRegKey = "\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "PagingFiles", "REG_MULTI_SZ", "C:\pagefile.sys 4096 4096")

    ;-----------------------------UAC
    Local $sRegKey = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "EnableLUA", "REG_DWORD", "0")

    ;-----------------------------USB Root Hub Power Management
    Local $sRegKey = "\HKLM\SYSTEM\CurrentControlSet\Services\USB"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "DisableSelectiveSuspend", "REG_DWORD", "1")

    ;-----------------------------Task Scheduler
    Local $sRegKey = "\SYSTEM\CurrentControlSet\services\Schedule"
    If @OSArch = "X64" Then
        $sRegKey = "HKLM64" & $sRegKey
    Else
        $sRegKey = "HKLM" & $sRegKey

    EndIf
    RegWrite($sRegKey, "Start", "REG_DWORD", "3")

    ;-----------------------------Msconfig

        $aRegKeys[0] = "IMJPMIG"
        $aRegKeys[1] = "CocCoc Update"
        $aRegKeys[2] = "Intel(R) Common User Interface"
        $aRegKeys[3] = "Java Platform SE Auto Updater"
        $aRegKeys[4] = "IgfxTray"
        $aRegKeys[5] = "HotKeysCmds"
        $aRegKeys[6] = "Vmware User process"
        $aRegKeys[7] = "ImScInst"
        $aRegKeys[8] = "hkcmd"
        $aRegKeys[9] = "igfxpers"
        $aRegKeys[10] = "StartCCC"
        $aRegKeys[11] = "USB3MON"
        $aRegKeys[12] = "CuHanhPlay"
        $aRegKeys[13] = "SynTPEnh"
        $aRegKeys[14] = "Quicktime Task"
        $aRegKeys[15] = "iTunesHelper"
        $aRegKeys[16] = "NvBackend"
        $aRegKeys[17] = "NvMctray"
        $aRegKeys[18] = "Persistence"
        $aRegKeys[19] = "SunJavaUpdateSched"
        $aRegKeys[20] = "ctfmon.exe"
        $aRegKeys[21] = "NvCpl"
        $aRegKeys[22] = "TINTSETP"
        $aRegKeys[23] = "jusched"
        $aRegKeys[24] = "CocCoc"
        $aRegKeys[25] = "IMEKRMIG"
        $aRegKeys[26] = "CCleaner Monitoring"
        $aRegKeys[27] = "Google Update"
        $aRegKeys[28] = "ShadowPlay"
        $aRegKeys[29] = "AppEx Accelerator UI"
        $aRegKeys[30] = "StartCN"
        $aRegKeys[31] = "DFX"
        $aRegKeys[32] = "Raptr"


        ; Loop to delete startup registry keys
        #requireAdmin
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
             ; Loop to delete startup registry keys
        For $g = 0 To UBound($aRegKeys) - 1
            RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            RegRead("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
            If @error <> 0 Then
                ; do nothing
            Else
                For $r = 0 To UBound($aRegKeys) - 1
                    RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    RegDelete("HKCU64\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                    Sleep(100)
                Next
            EndIf
         Next
         SplashOff()
    ;-----------------------------MsgBox
    MsgBox($MB_SYSTEMMODAL, "Hoàn thành", "Hoàn thành !")
    ;---------------------------
    Case $msconfig
    #requireadmin
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
    ShellExecute('msconfig.exe', -4) ; << 4 = which tab to display
    DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)
    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "MSConfig") ; << stops the message after reboot
    ;--------------- Device Manager----------
    Case $driver
        Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE)
    ;----------------Check Disk-------------
    Case $chkdsk
        Run(@ComSpec & " /c " & 'cmd.exe', "",  @SW_SHOW)
        ;-------3DP Chip
    Case $chip
        SplashTextOn("Thông báo", "Đang tải về....", 400, 55, -1, -1, 1, "Times New Roman", 24)
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/3DPChip.exe", @TempDir & "\3DPChip.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\3DPChip.exe")
    SplashOff()
        ;--------Info hardware
    Case $hwinfo
        SplashTextOn("Thông báo", "Đang tải về....", 400, 55, -1, -1, 1, "Times New Roman", 24)
    $Download=InetGet("https://googledrive.com/host/0B8kF-2k17yfIaEFpT2YzWHlRRms/Speccy.exe", @TempDir & "\Speccy.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
      Do
           Sleep(250)
        Until InetGetInfo($Download, $INET_DOWNLOADCOMPLETE)
    ShellExecute(@tempdir & "\Speccy.exe")
    SplashOff()
    ;-----------------------
    Case $GUI_EVENT_CLOSE
    If FileExists($TempDir & "CheckDisk.exe") Then
    FileDelete($TempDir & "CheckDisk.exe")
    EndIf
    If FileExists($TempDir & "3DP_Chip.exe") Then
    FileDelete($TempDir & "3DP_Chip.exe")
    EndIf
    If FileExists($TempDir & "Speccy.exe") Then
    FileDelete($TempDir & "Speccy.exe")
    EndIf
    If FileExists($TempDir & "ORTHOS.exe") Then
    FileDelete($TempDir & "ORTHOS.exe")
    EndIf
    If FileExists($TempDir & "worker.dll") Then
    FileDelete($TempDir & "worker.dll")
    EndIf
    Exit
    EndSwitch
    WEnd
     
    Sau 1 ngày mày mò cuối cùng cũng không làm được..:( cái checkbox and button en/disable
    Nhờ @Huân Hoàng giúp cho cái này, khi mình nhấn vào Button Optimize thì nó hiện ra 1 MsgBox hoặc Array thể hiện nó đang En/Disable Services nào. Bạn cho mình 1 cái code ví dụ nào đó để mình thử tự tìm hiểu nhé. Cảm ơn nhiều lắm
     
    kamsamita1 thích bài này.
  11. Huân Hoàng

    Huân Hoàng Administrator Thành viên BQT Administrator Super Moderator
    • 93/113

    Tham gia ngày:
    29/9/15
    Bài viết:
    642
    Đã được thích:
    1,181
    Ẹc, có đưa code rồi mà. Cái comment bên trên của mình, bạn bấm vào Spoiler:Click để xem code.
     
    kamsamita1 thích bài này.
  12. khidotdn

    khidotdn Thành viên mới
    • 1/6

    Tham gia ngày:
    18/11/15
    Bài viết:
    17
    Đã được thích:
    18
    Mình có 1 ý này, không cần phải làm BitAnd, nếu được thì bạn cho mình code chèn vào giữa những RunWait, nếu như chạy đến Services nào nó bị treo thì nó hiện MsgBox , nhưng chương trình vẫn tiếp tục chạy.
    Không biết mình sử dụng mã If có được ko ?
    Mã (Text):
    If @error ... then
     
    kamsamita1 thích bài này.
  13. Huân Hoàng

    Huân Hoàng Administrator Thành viên BQT Administrator Super Moderator
    • 93/113

    Tham gia ngày:
    29/9/15
    Bài viết:
    642
    Đã được thích:
    1,181
    Ủa, nhớ code cũ chạy được mà sao giờ bị lỗi thế :p Lỗi đó là do thiếu khai báo, thêm
    #include<GUIConstantsEx.au3>
    #include<MsgBoxConstants.au3>
    nếu chưa có
    Hoặc replace thằng $GUI_EVENT_CLOSE thành -3 cũng được.

    Riêng MsgBox nó sẽ làm chương trình dừng chứ không tiếp tục được, có thể thay bằng ConsoleWrite hoặc thêm vào giao diện 1 cái Input Control, nếu lỗi thì dùng GUICtrlSetData để hiển thị lỗi lên Input cũng được :D
     
    kamsamita1 thích bài này.
Trạng thái chủ đề:
Không mở trả lời sau này.

Chia sẻ trang này

Đang tải...