Categories: VBS | Tags: | Views: 853
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'on error resume next
'msgbox "All these settings are aviable till the browser restarted!",vbInformation,"ProxyShift" 

dim ws,pe,proxy,proxy1,proxycount,i,r
const REGDIR="HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings" 
 
Set ws = WScript.CreateObject("WScript.Shell")
readValues
if pe=0 then
    if msgbox("Proxy is disabled, enable it?",vbYesNo,"ProxyShift")=vbYes then
        if proxy="" then
            proxy=InputBox("Input proxy server","ProxyShift")
            if proxy<> "" then
                ws.RegWrite REGDIR &#038; "ProxyServer",proxy,"REG_SZ"
                ws.RegWrite REGDIR &#038; "ProxyServer1",proxy,"REG_SZ"
                ws.RegWrite REGDIR &#038; "ProxyCount","1","REG_SZ"
            end if
        else
            Call ChangeProxy
        end if
        ws.RegWrite REGDIR &#038; "ProxyEnable",1,"REG_DWORD"
        msgbox "ProxyServer setted!",vbInformation,"ProxyShift"
    end if
else
    r=msgbox("Proxy server list: " &#038; vbcrlf &#038; vbcrlf &#038; get_Proxystr &#038; vbcrlf &#038; "Disable or change it?" &#038; vbcrlf &#038; vbcrlf &#038; "[YES] for disable, [NO] for change",vbYesNoCancel,"ProxyShift")
    if r=vbYes then
        ws.RegWrite REGDIR &#038; "ProxyEnable",0,"REG_DWORD"
        msgbox "Proxy disabled!",vbInformation,"ProxyShift"
    elseif r=vbNo then
        Call ChangeProxy
        msgbox "ProxyServer setted!",vbInformation,"ProxyShift"
    end if
end if 
 
Function get_Proxystr
dim proxystr
proxystr=""
proxy=ws.RegRead(REGDIR &#038; "ProxyServer")
proxycount=ws.RegRead(REGDIR &#038; "ProxyCount")
for i=1 to proxycount
    proxy1=ws.RegRead(REGDIR &#038; "ProxyServer" &#038; i)
    if proxy1 = "" then proxy1 = proxy
    proxystr=proxystr &#038; i ". " &#038; proxy1
    if proxy1=proxy then proxystr = proxystr &#038; " (DEFAULT)"
    proxystr=proxystr &#038; vbcrlf
next
get_Proxystr=proxystr
end Function 
 
sub ChangeProxy
dim pindex
r=msgbox("Proxy server list:" &#038; vbcrlf &#038; vbcrlf &#038; get_Proxystr &#038; vbcrlf &#038; "Change the DEFAULT proxy server?" &#038; vbcrlf &#038; vbcrlf &#038; "[YES] for change, [NO] for a new proxy server, [CANCEL] for use default", vbYesNoCancel,"ProxyShift")
if r=vbYes then
    pindex=InputBox("Input proxy server index","ProxyShift")
    ws.RegWrite REGDIR &#038; "ProxyServer",ws.RegRead(REGDIR &#038; "ProxyServer" &#038; pindex),"REG_SZ"
    msgbox "Proxy server " &#038; pindex &#038; " set as default!",vbInformation,"ProxyShift"
elseif r=vbNo then
    dim newserver
    newserver=InputBox("Input a new proxy server:","ProxyShift")
    if newserver<>"" then
        ws.RegWrite REGDIR &#038; "ProxyServer",newserver,"REG_SZ"
        ws.RegWrite REGDIR &#038; "ProxyServer" &#038; proxycount+1,newserver,"REG_SZ"
        ws.RegWrite REGDIR &#038; "ProxyCount",proxycount+1,"REG_SZ"
        'msgbox "ProxyServer setted!",vbInformation,"ProxyShift"
    end if
end if
end sub 
 
sub readValues
on error resume next
proxy=ws.RegRead(REGDIR &#038; "ProxyServer")
proxycount=ws.RegRead(REGDIR &#038; "ProxyCount")
if isnull(proxycount) or proxycount="" then
    ws.RegWrite REGDIR &#038; "ProxyServer1",proxy,"REG_SZ"
    ws.RegWrite REGDIR &#038; "ProxyCount","1","REG_SZ"
end if
proxycount=ws.RegRead(REGDIR &#038; "ProxyCount")
pe=ws.RegRead(REGDIR &#038; "ProxyEnable")
end sub
这篇文章来自 迷途知返(PWWANG.COM), 转载请注明出处。 版权说明

No comments yet.
;) :| :x :twisted: :roll: :oops: :o :mrgreen: :lol: :idea: :evil: :cry: :arrow: :P :D :?: :? :) :( :!: 8O 8)

你可以使用@somebody:开头, 来邮件通知somebody你回复了他的留言(用户名区分大小写).