這VBScript是用於諾頓ConnectSave服務:
Option Explicit
Dim MessageArabe,MessageFr,MessageEn,Titre,Question,strComputer,objWMIService,colNetCards,objNetCard,arrDNSServers
MessageArabe = ChrW(1607)&ChrW(1604)&ChrW(32)&ChrW(1578)&ChrW(1585)&ChrW(1610)&ChrW(1583)&ChrW(32)&_
ChrW(1581)&ChrW(1580)&ChrW(1576)&ChrW(32)&ChrW(1575)&ChrW(1604)&_
ChrW(1605)&ChrW(1608)&ChrW(1575)&ChrW(1602)&ChrW(1593)&ChrW(32)&ChrW(1575)&ChrW(1604)&_
ChrW(1575)&ChrW(1576)&ChrW(1575)&ChrW(1581)&ChrW(1610)&ChrW(1577)&ChrW(32)&ChrW(1608)&_
ChrW(32)&ChrW(1575)&ChrW(1604)&ChrW(1582)&ChrW(1576)&ChrW(1610)&ChrW(1579)&ChrW(1577)
MessageFr = " Voulez-vous bloquer les sites pornographiques et malveillants avec le service NortonConnectSafe ?"
MessageEn = " Do you want to block pornographic and malicious websites with the NortonConnectSafe Service ?"
Titre = MessageArabe &" © Hackoo © 2015"
If AppPrevInstance() Then
MsgBox "Il y a une instance déjà en cours",VbExclamation,"Il y a une instance déjà en cours"
WScript.Quit
Else
Call ListDNSInfo()
End If
'****************************************************************************************************************
Question = MsgBox(MessageArabe & VbcrLf & MessageFr & VbcrLf & MessageEn,vbYesNoCancel+VbQuestion,Titre)
If Question = VbYes then
Call NortonConnectSafe(True)
End if
If Question = VbNo Then
Call NortonConnectSafe(False)
Else
Call ListDNSInfo()
Wscript.Quit()
End if
'****************************************************************************************************************
Sub NortonConnectSafe(Active)
Dim OKMsgAR,OKMsgFR,OKMsgEN,NoOKMsgAR,NoOKMsgFR,NoOKMsgEN
OKMsgAR = ChrW(1578)&ChrW(1605)&ChrW(32)&ChrW(1578)&ChrW(1606)&ChrW(1588)&ChrW(1610)&ChrW(1591)&ChrW(32)&ChrW(1582)&_
ChrW(1583)&ChrW(1605)&ChrW(1577)&ChrW(32)&ChrW(1571)&ChrW(1576)&ChrW(1606)&ChrW(1583)&ChrW(1606)&ChrW(1587)&ChrW(32)&_
ChrW(1576)&ChrW(1606)&ChrW(1580)&ChrW(1575)&ChrW(1581)&ChrW(33)
NoOKMsgAR = ChrW(1578)&ChrW(1605)&ChrW(32)&ChrW(1573)&ChrW(1604)&ChrW(1594)&ChrW(1575)&ChrW(1569)&ChrW(32)&ChrW(1582)&_
ChrW(1583)&ChrW(1605)&ChrW(1577)&ChrW(32)&ChrW(1571)&ChrW(1576)&ChrW(1606)&ChrW(1583)&ChrW(1606)&ChrW(1587)&ChrW(32)&_
ChrW(1576)&ChrW(1606)&ChrW(1580)&ChrW(1575)&ChrW(1581)&ChrW(33)
OKMsgFR = "Le service NortonConnectSafe est activé avec succès !"
NoOKMsgFR = "Le service NortonConnectSafe est désactivé avec succès !"
OKMsgEN = "The NortonConnectSafe service is successfully activated !"
NoOKMsgEN = "The NortonConnectSafe service is off successfully !"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
If Active = True Then
For Each objNetCard in colNetCards
arrDNSServers = Array("184.169.223.35", "199.85.126.30") 'DNS Norton ConnectSafe
objNetCard.SetDNSServerSearchOrder(arrDNSServers)
If Err = 0 Then
MsgBox OKMsgAR & VbCrlF & OKMsgFR & VbCrlF & OKMsgEN,VbInformation, OKMsgAR & OKMsgFR
Call ListDNSInfo()
Else
'MsgBox Err.Description,Vbcritical,Err.Description
End If
Next
Else
For Each objNetCard in colNetCards
objNetCard.SetDNSServerSearchOrder(null)
If Err = 0 Then
MsgBox NoOKMsgAR & VbCrlF & NoOKMsgFR & VbCrlF & NoOKMsgEN,VbExclamation,NoOKMsgAR & NoOKMsgFR
Call ListDNSInfo()
Else
'MsgBox Err.Description,Vbcritical,Err.Description
End If
Next
End If
End Sub
'*****************************************************************************************************************
Sub ListDNSInfo()
Dim ComputerName,IPConfigSet,IPConfig,BailObtenu,BailExpirant
ComputerName="."
On error resume next
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & ComputerName).ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
If Err.Number<>0 Then
wscript.echo " - non accessible -"
Else
for each IPConfig in IPConfigSet
BailObtenu = IPConfig.DHCPLeaseObtained
BailExpirant = IPConfig.DHCPLeaseExpires
'---- Convertion des date et heure d'obtention et d'expiration des baux DHCP en un format lisible par l'utilisateur. ----
BailObtenu = mid(BailObtenu, 7, 2) & "/" & mid(BailObtenu, 5, 2) & "/" & mid(BailObtenu, 1, 4) & " - " & mid(BailObtenu, 9, 2)& ":" & mid(BailObtenu, 11, 2)& ":" & mid(BailObtenu, 13, 2)
BailExpirant = mid(BailExpirant, 7, 2) & "/" & mid(BailExpirant, 5, 2) & "/" & mid(BailExpirant, 1, 4) & " - " & mid(BailExpirant, 9, 2)& ":" & mid(BailExpirant, 11, 2)& ":" & mid(BailExpirant, 13, 2)
MsgBox " Configuration réseau de l'ordinateur " & ComputerName & vbcrlf & vbcrlf & _
"Nom Machine " & vbtab & " : " & IPConfig.DNSHostName & vbcrlf & _
"Carte active" & vbtab & " : " & IPConfig.Description & vbcrlf & _
"Adresse MAC " & vbtab & " : " & IPConfig.MACAddress & vbcrlf & _
"DHCP Activé" & vbtab & " : " & IPConfig.DHCPEnabled & vbcrlf & _
"Adresse IP " & vbtab & " : " & IPConfig.IPAddress(0) & vbcrlf & _
"Masque " & vbtab & vbtab & " : " & IPConfig.IPSubnet(0) & vbcrlf & _
"Passerelle " & vbtab & " : " & IPConfig.DefaultIPGateway(0) & vbcrlf & _
"Serveur DHCP " & vbtab & " : " & IPConfig.DHCPServer & vbcrlf & vbcrlf & _
"Serveur DNS " & vbtab & " : " & IPConfig.DNSServerSearchOrder(0) & vbcrlf & _
" " & vbtab & vbtab & " : " & IPConfig.DNSServerSearchOrder(1) & vbcrlf & _
"Serveur WINS " & vbtab & " : " & IPConfig.WINSPrimaryServer(0) & vbcrlf & _
" " & vbtab & vbtab & " : " & IPConfig.WINSSecondaryServer(0) & vbcrlf & vbcrlf & _
" Bail obtenu " & vbtab & " : " & BailObtenu & vbcrlf & _
" Bail expirant " & vbtab & " : " & BailExpirant _
,VbInformation,"Configuration réseau de l'ordinateur "
Next
End If
End Sub
'**************************************************************************
Function AppPrevInstance()
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
" AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")
AppPrevInstance = (.Count > 1)
End With
End With
End Function
'**************************************************************************
Function CommandLineLike(ProcessPath)
ProcessPath = Replace(ProcessPath, "\", "\\")
CommandLineLike = "'%" & ProcessPath & "%'"
End Function
'**************************************************************************
代碼的下半年應該是改變的DNS服務器完全足夠。如果在第二個'strComputer =「。」''之前刪除所有內容,是否有什麼不起作用?你是否以管理員權限運行這個? – 2014-10-27 20:54:38
我是一個巨大的白癡。我沒有作爲管理員運行。我期待Windows在這種情況下拋出一個錯誤。謝謝! – jasonrw 2014-10-28 12:02:45