用vbs实现自动检查代理是否可用,并自动设置IE代理的脚本

2019-01-16 06:16:55于丽

function confirm(s)
    confirm = (msgbox(s,vbYesNo,s) = 6)
end function

Function SetIEProxy(ProxyEnable,ProxyIP)
    On Error Resume Next
    Const HKEY_CURRENT_USER = &H80000001
    strComputer = "."
    Set objReg = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}" & strComputer & _
            "rootdefault:StdRegProv")

    strKeyPath = "SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
    strEntryName = "ProxyEnable"
    dwvalue = ProxyEnable
    objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strEntryName,dwValue

    strEntryName = "ProxyServer"
    dwvalue = ProxyIP
    objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName,dwValue
    If Err = 0 Then
        SetIEProxy = True
    Else
        SetIEProxy = False
    End If
End Function

msgbox "ok"