VBS 强制关闭Symantec Endpoint Protection的代码

2019-01-15 23:02:48王冬梅


' ====================================================================================================
' 读写注册表
Function RegRead( strKey )
    On Error Resume Next
    Set wso = CreateObject("WScript.Shell")
    RegRead = wso.RegRead( strKey )    'strKey = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRunDocTip"
    If IsArray( RegRead ) Then RegRead = Join(RegRead, VbCrLf)
    Set wso = Nothing
End Function
' 写注册表
Function RegWrite( strKey, strKeyVal, strKeyType )
    On Error Resume Next
    Dim fso, strTmp
    RegWrite = Flase
    Set wso = CreateObject("WScript.Shell")
    wso.RegWrite strKey, strKeyVal, strKeyType
    strTmp = wso.RegRead( strKey )
    If strTmp <> "" Then RegWrite = True
    Set wso = Nothing
End Function

' ====================================================================================================
' 读写INI文件(Unicode)   ReadIniUnicode / WriteIniUnicode
' This subroutine writes a value to an INI file
'
' Arguments:
' myFilePath  [string]  the (path and) file name of the INI file
' mySection   [string]  the section in the INI file to be searched
' myKey           [string]  the key whose value is to be written
' myValue         [string]  the value to be written (myKey will be
'                                           deleted if myValue is <DELETE_THIS_VALUE>)
'
' Returns:
' N/A
'
' CAVEAT:         WriteIni function needs ReadIniUnicode function to run
'
' Written by Keith Lacelle
' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude
Sub WriteIniUnicode( myFilePath, mySection, myKey, myValue )
        On Error Resume Next

        Const ForReading   = 1
        Const ForWriting   = 2
        Const ForAppending = 8
        Const TristateTrue = -1

        Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten
        Dim intEqualPos
        Dim objFSO, objNewIni, objOrgIni, wshShell
        Dim strFilePath, strFolderPath, strKey, strLeftString
        Dim strLine, strSection, strTempDir, strTempFile, strValue