好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > VBS實現的系統服務備份優化代碼

VBS實現的系統服務備份優化代碼

熱門標簽:辦理膠州400電話財稅 打電話的外呼系統貴不貴 海外美發店地圖標注 前鋒辦理400電話申請 陜西高頻外呼回撥系統哪家好 新密防封卡外呼系統違法嗎 外呼營銷下單系統 百度地圖標注怎么卸載 加盟電銷機器人好的品牌
復制代碼 代碼如下:

Option Explicit
'○○○○○○○○○○○○○○○○○○○○○○○○○○○○○開始
Const blnVBSShowCaption=True
'生成的服務備份中是否添加說明
Const blnVBSShowDescription=True
'●●●●●●●●●●●●●●●●●●●●●●●●●●●●●結束
'文件讀寫標識常量
Const Forwriteing = 8
'讀取出來的自動模式類型
Const cstrAutoForRead="Auto"
'用于設定的自動模式類型
Const cstrAutoForWrite="Automatic"
'變更歷史狀態
Const cstrStateNotFound="Not Found"
Const cstrStateNotSetted="Not Setted"
Const cstrStateNotChanged="Not Changed"
Const cstrStateChanged="Changed"
'服務變更類型
Class clsServiceChange
    '服務名稱
    Public Name
    '服務顯示名稱
    Public Caption
    '服務描述
    Public Description
    '服務初始啟動模式
    Public StartModeFrom
    '服務之后啟動模式
    Public StartModeTo
    '服務啟動變更標識
    Private Sub Class_Initialize()
        Name=""
        Caption=""
        Description=""
        StartModeFrom=""
        StartModeTo=""
    End Sub
    Public Property get State
        If StartModeFrom="" Then
            State="Not Found"
            Exit Property
        End If
        If StartModeTo="" Then
            State="Not Setted"
            Exit Property
        End If
        If StartModeFrom=StartModeTo Then
            State="Not Changed"
        Else
            State="Changed"
        End If
    End Property
End Class
'文件系統
dim objFileSystem
'備份的VBS文件
Dim objVBSFile
'WshShell 對象
dim objWShell
'windows 系統管理模塊
Dim objWinManagment
'系統服務集
Dim objServices
'所操作的電腦標識
Dim strComputer
'備份文件路徑
Dim strVBSFilePath
'備份文件名
Dim strVBSFileName
'信息
Dim strMessage
'數組索引
Dim intIndex
'Log暫存
Dim astrLog()
'服務變更歷史
Dim aobjServiceChange()
Redim aobjServiceChange(0)
Redim astrLog(0)
'添加多條變更原則
'○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○
'自己修改位置(開始)
'○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○
AddRuler "Alerter"    ,"Disabled"
AddRuler "ALG"    ,"Manual"
AddRuler "AppMgmt"    ,"Manual"
AddRuler "aspnet_state"    ,"Disabled"
AddRuler "Ati HotKey Poller"    ,"Disabled"
AddRuler "AudioAddRuler"    ,"Auto"
AddRuler "BITS"    ,"Manual"
AddRuler "Browser"    ,"Disabled"
AddRuler "CiSvc"    ,"Disabled"
AddRuler "ClipSrv"    ,"Disabled"
AddRuler "ClipAddRuler"    ,"Disabled"
AddRuler "COMSysApp"    ,"Disabled"
AddRuler "CryptSvc"    ,"Auto"
AddRuler "DcomLaunch"    ,"Auto"
AddRuler "DF5Serv"    ,"Auto"
AddRuler "Dhcp"    ,"Auto"
AddRuler "dmadmin"    ,"Manual"
AddRuler "dmserver"    ,"Manual"
AddRuler "Dnscache"    ,"Disabled"
AddRuler "ERSvc"    ,"Disabled"
AddRuler "Eventlog"    ,"Auto"
AddRuler "EventSystem"    ,"Auto"
AddRuler "FastUserSwitchingCompatibility"    ,"Disabled"
AddRuler "helpsvc"    ,"Manual"
AddRuler "HidServ"    ,"Disabled"
AddRuler "HTTPFilter"    ,"Manual"
AddRuler "ImapiService"    ,"Disabled"
AddRuler "lanmanserver"    ,"Manual"
AddRuler "lanmanworkstation"    ,"Auto"
AddRuler "LmHosts"    ,"Disabled"
AddRuler "MDM"    ,"Disabled"
AddRuler "Messenger"    ,"Disabled"
AddRuler "mnmAddRulerc"    ,"Manual"
AddRuler "mnmsrvc" , "Disabled"
AddRuler "MSDTC"    ,"Disabled"
AddRuler "MSIServer"    ,"Manual"
AddRuler "NetDDE"    ,"Disabled"
AddRuler "NetDDEdsdm"    ,"Disabled"
AddRuler "Netlogon"    ,"Manual"
AddRuler "Netman"    ,"Auto"
AddRuler "Nla"    ,"Disabled"
AddRuler "NtLmSsp"    ,"Manual"
AddRuler "NtmsSvc"    ,"Disabled"
AddRuler "NVSvc"    ,"Disabled"
AddRuler "OO Defrag"    ,"Manual"
AddRuler "ose"    ,"Manual"
AddRuler "PlugPlay"    ,"Auto"
AddRuler "PolicyAgent"    ,"Disabled"
AddRuler "ProtectedStorage"    ,"Auto"
AddRuler "RasAuto"    ,"Disabled"
AddRuler "RasMan"    ,"Disabled"
AddRuler "RDSessMgr"    ,"Disabled"
AddRuler "RemoteAccess"    ,"Disabled"
AddRuler "RemoteRegistry"    ,"Disabled"
AddRuler "RpcLocator"    ,"Manual"
AddRuler "RpcSs"    ,"Auto"
AddRuler "RSVP"    ,"Disabled"
AddRuler "SamSs"    ,"Auto"
AddRuler "SCardSvr"    ,"Disabled"
AddRuler "Schedule"    ,"Disabled"
AddRuler "seclogon"    ,"Auto"
AddRuler "SENS"    ,"Disabled"
AddRuler "SharedAccess"    ,"Disabled"
AddRuler "ShellHWDetection"    ,"Manual"
AddRuler "sicentnetsync"    ,"Auto"
AddRuler "Spooler"    ,"Manual"
AddRuler "srservice"    ,"Disabled"
AddRuler "SSDPAddRuler"    ,"Disabled"
AddRuler "SSDPSRV"    ,"Disabled"
AddRuler "stisvc"    ,"Manual"
AddRuler "SwPrv"    ,"Disabled"
AddRuler "SysmonLog"    ,"Manual"
AddRuler "TapiAddRuler"    ,"Manual"
AddRuler "TermService"    ,"Disabled"
AddRuler "Themes"    ,"Auto"
AddRuler "TlntSvr"    ,"Disabled"
AddRuler "TrkWks"    ,"Disabled"
AddRuler "TapiSrv"    ,"Disabled"
AddRuler "UMWdf"    ,"Auto"
AddRuler "upnphost"    ,"Disabled"
AddRuler "UPS"    ,"Disabled"
AddRuler "usnjsvc"    ,"Manual"
AddRuler "VSS"    ,"Disabled"
AddRuler "VMAuthdService"    ,"Manual"
AddRuler "VMnetDHCP"    ,"Manual"
AddRuler "VMware NAT Service"    ,"Manual"
AddRuler "W32Time"    ,"Disabled"
AddRuler "WebClient"    ,"Disabled"
AddRuler "winmgmt"    ,"Auto"
AddRuler "WinVNC4"    ,"Manual"
AddRuler "WmdmPmSN"    ,"Disabled"
AddRuler "Wmi"    ,"Manual"
AddRuler "WmiApAddRuler"    ,"Manual"
AddRuler "wscsvc"    ,"Manual"
AddRuler "wuauserv"    ,"Disabled"
AddRuler "WZCSVC"    ,"Auto"
AddRuler "xmlprov"    ,"Manual"
'●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
'自己修改位置(結束)
'●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
'設定電腦為本機
strComputer = "."
Set objWShell = CreateObject("Wscript.Shell")
'備份至我的文檔
strVBSFilePath = objWShell.SpecialFolders("MyDocuments") "\ServiceBack\"
'以當前時間作為備份文件名
strVBSFileName = "Service" Year(Date) "-" Month(Date) "-" Day(Date) "-" Hour(Time) "-" Minute(Time) ".vbs"
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
'備份文件路徑存在性驗證和添加文件夾
If Not objFileSystem.FolderExists(strVBSFilePath) Then
    objFileSystem.CreateFolder(strVBSFilePath)
End If
'備份文件存在性驗證
If objFileSystem.FileExists(strVBSFilePath strVBSFileName) Then
    '文件存在的情況下
    Msgbox "The File Has been in existence.",16,"Warning!"
Else
    '本機管理模塊對象初始化
    Set objWinManagment = GetObject("Winmgmts:\\" strComputer "\Root\Cimv2")
    '本機服務集取得
    Set objServices =objWinManagment.ExecQuery("Select * From Win32_Service")
    '文件對象創建
    Set objVBSFile = objFileSystem.CreateTextFile(strVBSFilePath  strVBSFileName ,ForWriteing)
    objVBSFile.WriteLine vbcrlf
    objVBSFile.WriteLine "'Runable Backup:"
    objVBSFile.WriteLine "'============================="
    objVBSFile.WriteLine "Const cstrAutoForRead=""Auto"""
    objVBSFile.WriteLine "Const cstrAutoForWrite=""Automatic"""
    objVBSFile.WriteLine "intChangeCount=0"
    objVBSFile.WriteLine "intChangeSuccessCount=0"
    objVBSFile.WriteLine "strComputer = ""."""
    objVBSFile.WriteLine "Const Forwriteing = 8"
    objVBSFile.WriteLine "If Msgbox(""Are You Sure You Want To Restore Your Service ?"",VBYesNo+vbInformation,""Restore Service"")=vbYes Then"
    objVBSFile.WriteLine "    Set objWinManagment = GetObject(""Winmgmts:\\"" strComputer ""\Root\Cimv2"")"
    objVBSFile.WriteLine "    Set objServices =objWinManagment.ExecQuery(""Select * From Win32_Service"")"
    strMessage = GOT()
    objVBSFile.WriteLine "    Set objWinManagment = Nothing"
    objVBSFile.WriteLine "    Set objServices =Nothing"
    objVBSFile.WriteLine "End If"
    objVBSFile.WriteLine "Function SRV(SRN,SRM)"
    objVBSFile.WriteLine "    For Each S In objServices"
    objVBSFile.WriteLine "        If s.Name = Srn And S.StartMode>SRM Then"
    objVBSFile.WriteLine "           intChangeCount=intChangeCount+1 "
    objVBSFile.WriteLine "           If SRM=cstrAutoForRead Then "
    objVBSFile.WriteLine "               strStartModeTemp=cstrAutoForWrite "
    objVBSFile.WriteLine "           Else "
    objVBSFile.WriteLine "               strStartModeTemp=SRM "
    objVBSFile.WriteLine "           End If "
    objVBSFile.WriteLine "           If S.ChangeStartMode(strStartModeTemp)=0 Then "
    objVBSFile.WriteLine "               intChangeSuccessCount=intChangeSuccessCount+1 "
    objVBSFile.WriteLine "           End If "
    objVBSFile.WriteLine "        End if"
    objVBSFile.WriteLine "    Next"
    objVBSFile.WriteLine "End Function"
    If Msgbox ("Backup services Completed" Chr(13) strVBSFilePath  strVBSFileName Chr(13) "'(" strMessage ")" "Begin optimization?",VBYesNo+vbInformation,"Complete" ) = vbYes Then
        '執行服務設置
        strMessage=SRV
        Msgbox "Optimization completed!restart Your computer?" Chr(13) "'(" strMessage ")",vbOKOnly+vbInformation,"OK"
'        If Msgbox("Optimization completed!restart Your computer?" Chr(13) "'(" strMessage ")",VBYesNo+vbInformation,"OK") = vbYes Then
'          objWShell.Run "Shutdown.exe -r -t 5"
'        End if  
    End if
    'Log輸出
    Call OutputLog
    '備份文件關閉
    objVBSFile.Close
End if
'對象釋放
For intIndex=0 To Ubound(aobjServiceChange)
    Set aobjServiceChange(intIndex)= Nothing
Next
Erase aobjServiceChange   
Erase astrLog
Set objFileSystem=Nothing
Set objVBSFile=Nothing
Set objWShell=Nothing
Set objWinManagment=Nothing
Set objServices=Nothing
Wscript.quit
''''''''''''''''''''''''''''''''''
'記錄Log信息
''''''''''''''''''''''''''''''''''
Function WriteLog(strTemp)
    '檢測當前數組值是否被初始化并初始化為空值
    If Isempty(astrLog(Ubound(astrLog))) Then
        astrLog(Ubound(astrLog))=""
    End If
    astrLog(Ubound(astrLog))=astrLog(Ubound(astrLog)) strTemp
End Function
''''''''''''''''''''''''''''''''''
'按行記錄Log信息
''''''''''''''''''''''''''''''''''
Function WriteLineLog(strTemp)
    '檢測當前數組值是否被初始化并初始化為空值
    If Isempty(astrLog(Ubound(astrLog))) Then
        astrLog(Ubound(astrLog))=""
    End If
    astrLog(Ubound(astrLog))=astrLog(Ubound(astrLog)) strTemp
    Redim Preserve astrLog(Ubound(astrLog)+1)
    astrLog(Ubound(astrLog))=""
End Function
''''''''''''''''''''''''''''''''''
'輸出Log信息
''''''''''''''''''''''''''''''''''
Function OutputLog()
    '數組計數器
    Dim intIndex
    'Log輸出出錯計數
    Dim intLogOutputError
    intLogOutputError=0
    For intIndex=0 To Ubound(astrLog)
        On Error Resume Next
            objVBSFile.WriteLine "'" astrLog(intIndex)
            If Err.Number>0 Then
                intLogOutputError=intLogOutputError+1
                objVBSFile.WriteLine "'???????????????Illegal Code????????????????"
            End If
        On Error Goto 0
    Next
    If intLogOutputError>0 Then
        objVBSFile.WriteLine "'???????????????Log Output Error(" intLogOutputError ")????????????????"
    End If
End Function
''''''''''''''''''''''''''''''
'添加變更原則
'''''''''''''''''''''''''''''''''
Function AddRuler(SRN,SRM)
    Dim intIndex
    '遍歷所有已經存在服務以防止重復
    For intIndex=0 To Ubound(aobjServiceChange)-1
        If aobjServiceChange(intIndex).Name=SRN Then
            WriteLineLog "???????????????" SRN "'s Ruler duplicated ????????????????"
            Exit Function
        End If
    Next
    Set aobjServiceChange(Ubound(aobjServiceChange))=New clsServiceChange
    '記錄服務名稱
    aobjServiceChange(Ubound(aobjServiceChange)).Name=SRN
    '記錄服務要變更成的啟動模式
    aobjServiceChange(Ubound(aobjServiceChange)).StartModeTo=SRM
    Redim Preserve aobjServiceChange(Ubound(aobjServiceChange)+1)
End Function
''''''''''''''''''''''''''''''
'服務狀態取得備份
''''''''''''''''''''''''''''''
Function GOT()
    '系統服務
    Dim objService
    '服務名
    Dim strServiceName
    '服務顯示名
    Dim strServiceCaption
    '服務啟動模式
    Dim strServiceMode
    '服務描述
    Dim strServiceDescription
    '變更計數
    Dim intChangeCount
    '有效規則計數
    Dim intRuleredCount
    '規則計數
    Dim intRuler
    '數組索引
    Dim intIndex
    '與規則匹配上標識
    Dim blnMatch
    intChangeCount=0
    intRuleredCount=0
    intRuler=Ubound(aobjServiceChange)-1
    WriteLineLog vbcrlf
    WriteLineLog "Optimize Needed:"
    WriteLineLog "============================="
    For Each objService in objServices
        blnMatch=False
        strServiceName = objService.Name
        strServiceCaption=objService.Caption
        strServiceMode = objService.StartMode
        strServiceDescription=objService.Description
        If IsNull(strServiceDescription) Then
            strServiceDescription=""
        End If
        strServiceDescription=Replace(strServiceDescription,vbcrlf,"")
        '是否在備份代碼中顯示說明
        If blnVBSShowCaption Then
            objVBSFile.Write "'"
            '避免出現亂碼的情況出錯
            On Error Resume Next
                objVBSFile.Write "(" strServiceCaption ") "
                '是否在備份代碼中顯示說明
                If blnShowDescription Then
                    objVBSFile.Write " [" strServiceDescription "]"
                End If
                objVBSFile.Writeline ""
                Err.clear
            On Error Goto 0
        End If
        objVBSFile.WriteLine "    SRV """ strServiceName """,""" strServiceMode """"
        '變更檢測(用于Log輸出)
        For intIndex=0 To Ubound(aobjServiceChange)-1
            '驗證是否名稱相同
            If strServiceName=aobjServiceChange(intIndex).Name Then
                '修改是否匹配上的標識
                blnMatch=True
                '記錄匹配上的數目
                intRuleredCount=intRuleredCount+1
                '記錄服務起始啟動方式
                aobjServiceChange(intIndex).StartModeFrom=strServiceMode
                '記錄服務顯示名稱
                aobjServiceChange(intIndex).Caption=strServiceCaption
                '記錄服務描述
                aobjServiceChange(intIndex).Description=strServiceDescription
                '驗證是否需要變更
                If strServiceMode>aobjServiceChange(intIndex).StartModeTo Then
                    '需要變更計數
                    intChangeCount=intChangeCount+1
                    WriteLineLog strServiceName vbTab "(" strServiceCaption ")"  "[" strServiceDescription "]"
                    WriteLineLog strServiceMode vbTab "--->" vbTab aobjServiceChange(intIndex).StartModeTo
                End If
                '查找到服務之后退出循環
                Exit For
            End If
        Next
        '在規則中未規定的服務添加
        If blnMatch=False then
            Set aobjServiceChange(Ubound(aobjServiceChange))=New clsServiceChange
            '記錄服務名稱
            aobjServiceChange(Ubound(aobjServiceChange)).Name=objService.Name
            '記錄服務別名
            aobjServiceChange(Ubound(aobjServiceChange)).Caption=objService.Caption
            '記錄服務描述
            aobjServiceChange(Ubound(aobjServiceChange)).Description=objService.Description
            '記錄服務初始的啟動模式
            aobjServiceChange(Ubound(aobjServiceChange)).StartModeFrom=objService.StartMode
            Redim Preserve aobjServiceChange(Ubound(aobjServiceChange)+1)
        End If
    Next
    objVBSFile.WriteLine "    Msgbox ""Service Reset Completed"" ""("" intChangeSuccessCount ""/"" intChangeCount "")"" "
    GOT="Service:" objServices.Count  ",Ruler:" intRuler ",Rulered:" intRuleredCount ",NotRulered:" objServices.Count-intRuleredCount ",ChangeNeed:" intChangeCount ""
    WriteLineLog "***********************************************************************************"
    WriteLineLog GOT
    WriteLineLog "***********************************************************************************"
    '輸出未做規定的
    WriteLineLog vbcrlf
    WriteLineLog "-----------------------------"
    WriteLineLog "Not Rulered:"
    WriteLineLog "-----------------------------"
    '遍歷變更歷史
    For intIndex=0 To Ubound(aobjServiceChange)-1
        '服務變更狀態檢測
        If aobjServiceChange(intIndex).State=cstrStateNotSetted Then
            '未設定的服務信息輸出
            WriteLineLog """" aobjServiceChange(intIndex).Name  """" vbTab ",""" aobjServiceChange(intIndex).StartModeFrom """" vbTab "(" aobjServiceChange(intIndex).Caption ")" "[" aobjServiceChange(intIndex).Description "]"
        End If
    Next
    '清空對象
    Set objService=Nothing
End Function
''''''''''''''''''''''''''''''''''''''''''''
'服務設定函數
''''''''''''''''''''''''''''''''''''''''''''
Function SRV()
    '系統服務
    Dim objService
    '數組計數
    Dim intIndex
    '服務描述
    Dim strServiceDescription
    '要設定的服務啟動方式暫存
    Dim strStartModeTemp
    '服務啟動方式修改成功計數
    Dim intChangeSuccessCount
    '服務啟動方式修改不成功計數
    Dim intChangeNotSuccessCount
    intChangeSuccessCount=0
    intChangeNotSuccessCount=0
    WriteLineLog vbcrlf
    WriteLineLog "============================="
    WriteLineLog "Optimize Record:"
    WriteLineLog "============================="
    '修改失敗的Log標題
    WriteLineLog "-----------------------------"
    WriteLineLog "Change False:"
    WriteLineLog "-----------------------------"
    '遍歷服務集
    For Each objService In objServices
        For intIndex=0 To Ubound(aobjServiceChange)-1
            If objService.Name=aobjServiceChange(intIndex).Name Then
                '啟動方式判斷
                If aobjServiceChange(intIndex).State=cstrStateChanged Then
                    '修改啟動方式
                    If aobjServiceChange(intIndex).StartModeTo=cstrAutoForRead Then
                        '要設定啟動類型為自啟動時
                        strStartModeTemp=cstrAutoForWrite
                    Else
                        '設定服務類型不是自啟動時
                        strStartModeTemp=aobjServiceChange(intIndex).StartModeTo
                    End If
                    '修改服務啟動方式
                    If objService.ChangeStartMode(strStartModeTemp)=0 Then
                        '修改成功計數
                        intChangeSuccessCount=intChangeSuccessCount+1
                    Else
                        '修改不成功計數
                        intChangeNotSuccessCount=intChangeNotSuccessCount+1
                        '記錄未修改成功的服務
                        WriteLineLog objService.Name "(" objService.Caption ")" "[" objService.Description "]"
                        '記錄該服務所應該做的變更
                        WriteLineLog objService.StartMode vbTab "--->" vbTab aobjServiceChange(intIndex).StartModeTo
                    End If
                End If
                '查找到服務之后退出循環
                Exit For
            End If
        Next
    Next
    SRV="Successed:" intChangeSuccessCount ",NotSuccessed:" intChangeNotSuccessCount
    WriteLineLog "***********************************************************************************"
    WriteLineLog SRV
    WriteLineLog "***********************************************************************************"
    '清空對象
    Set objService=Nothing
End Function

標簽:阜陽 梅州 咸陽 河南 武威 牡丹江 伊春 四平

巨人網絡通訊聲明:本文標題《VBS實現的系統服務備份優化代碼》,本文關鍵詞  VBS,實現,的,系統,服務,備份,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《VBS實現的系統服務備份優化代碼》相關的同類信息!
  • 本頁收集關于VBS實現的系統服務備份優化代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 啊好大好爽视频| 将军跪撅含玉势绳衣调教小说| 精品乱码二区三四区视频特点 | 1000部拍拍视频18勿入| 性生生活1~5集观看| 色淫片| 黄色一级片免费| 天堂最新版在线地址| 国产成人亚洲综合A∨婷婷| 三个男人躁我一个爽小芳视频| 白丝袜| 未成年在线完整版观看| 高辣h文乱乳H文浪荡岳妇| 99国产在线有香蕉| 凌调教餐厅ova无修在线观看| 亚洲人在线| 99精品国产成人一区二区在线| 美女胸又黄又???| 国产又黄又爽又色又刺激视频| 伊人色视频| 含着整晚都没拔出来H| 台湾一级毛片高清免费观看视频| 强壮的公次次弄得我高潮A片小说| 久久久国产精品免费| 欧美主妇出轨交换电影| 恩恩呜呜好大好爽快点| 国产日韩va欧美va在线观看| 麻豆视频免费网站| 暗呦丨小u女国产精品| 国产日韩欧美一区二区三区乱码| 美女光着胸给男生玩| 手机看片av| 国产高清精品久久久久久久| 按着她的腰狠狠地顶撞她| 8090午夜无码国产| 嗯啊不要嘛| 久久精彩视频| 虐之恋电影| 边摸边吃奶叫床激情视频| 欧美成人午夜视频在线观看| 亚洲AV永久无码国产精品久久|