Iska
07-06-2018, 17:02
Sisin, а если тогда вот так — просто временно, на время работы Setup.exe, создавать пару правил для фаерволла:
Option Explicit
Const strSourceFileName = "Setup.exe"
Const NET_FW_IP_PROTOCOL_ANY = 256
Const NET_FW_RULE_DIR_IN = 1
Const NET_FW_RULE_DIR_OUT = 2
Const NET_FW_ACTION_BLOCK = 0
Dim strSourceFile
Dim objNetFwPolicy2
Dim objNetFwRule2
With WScript.CreateObject("Scripting.FileSystemObject")
strSourceFile = .BuildPath(.GetParentFolderName(WScript.ScriptFullName), strSourceFileName)
If Not .FileExists(strSourceFile) Then
WScript.Echo "Can't find source file [" & strSourceFile & "]."
WScript.Quit 1
End If
End With
Set objNetFwPolicy2 = WScript.CreateObject("HNetCfg.FwPolicy2")
For Each objNetFwRule2 In objNetFwPolicy2.Rules
If StrComp(objNetFwRule2.ApplicationName, strSourceFile, vbTextCompare) = 0 Then
objNetFwPolicy2.Rules.Remove objNetFwRule2.Name
End If
Next
Set objNetFwRule2 = WScript.CreateObject("HNetCfg.FWRule")
With objNetFwRule2
.Name = "My Installer"
.Description = "Disallow My Installer network traffic"
.ApplicationName = strSourceFile
.Protocol = NET_FW_IP_PROTOCOL_ANY
.Profiles = objNetFwPolicy2.CurrentProfileTypes
.Direction = NET_FW_RULE_DIR_IN
.Action = NET_FW_ACTION_BLOCK
.Enabled = True
End With
objNetFwPolicy2.Rules.Add objNetFwRule2
Set objNetFwRule2 = Nothing
Set objNetFwRule2 = WScript.CreateObject("HNetCfg.FWRule")
With objNetFwRule2
.Name = "My Installer"
.Description = "Disallow My Installer network traffic"
.ApplicationName = strSourceFile
.Protocol = NET_FW_IP_PROTOCOL_ANY
.Profiles = objNetFwPolicy2.CurrentProfileTypes
.Direction = NET_FW_RULE_DIR_OUT
.Action = NET_FW_ACTION_BLOCK
.Enabled = True
End With
objNetFwPolicy2.Rules.Add objNetFwRule2
Set objNetFwRule2 = Nothing
WScript.CreateObject("WScript.Shell").Run """" & strSourceFile & """", 1, True
For Each objNetFwRule2 In objNetFwPolicy2.Rules
If StrComp(objNetFwRule2.ApplicationName, strSourceFile, vbTextCompare) = 0 Then
objNetFwPolicy2.Rules.Remove objNetFwRule2.Name
End If
Next
WScript.Quit 0
?!
Кривовастенько, конечно, да…
Option Explicit
Const strSourceFileName = "Setup.exe"
Const NET_FW_IP_PROTOCOL_ANY = 256
Const NET_FW_RULE_DIR_IN = 1
Const NET_FW_RULE_DIR_OUT = 2
Const NET_FW_ACTION_BLOCK = 0
Dim strSourceFile
Dim objNetFwPolicy2
Dim objNetFwRule2
With WScript.CreateObject("Scripting.FileSystemObject")
strSourceFile = .BuildPath(.GetParentFolderName(WScript.ScriptFullName), strSourceFileName)
If Not .FileExists(strSourceFile) Then
WScript.Echo "Can't find source file [" & strSourceFile & "]."
WScript.Quit 1
End If
End With
Set objNetFwPolicy2 = WScript.CreateObject("HNetCfg.FwPolicy2")
For Each objNetFwRule2 In objNetFwPolicy2.Rules
If StrComp(objNetFwRule2.ApplicationName, strSourceFile, vbTextCompare) = 0 Then
objNetFwPolicy2.Rules.Remove objNetFwRule2.Name
End If
Next
Set objNetFwRule2 = WScript.CreateObject("HNetCfg.FWRule")
With objNetFwRule2
.Name = "My Installer"
.Description = "Disallow My Installer network traffic"
.ApplicationName = strSourceFile
.Protocol = NET_FW_IP_PROTOCOL_ANY
.Profiles = objNetFwPolicy2.CurrentProfileTypes
.Direction = NET_FW_RULE_DIR_IN
.Action = NET_FW_ACTION_BLOCK
.Enabled = True
End With
objNetFwPolicy2.Rules.Add objNetFwRule2
Set objNetFwRule2 = Nothing
Set objNetFwRule2 = WScript.CreateObject("HNetCfg.FWRule")
With objNetFwRule2
.Name = "My Installer"
.Description = "Disallow My Installer network traffic"
.ApplicationName = strSourceFile
.Protocol = NET_FW_IP_PROTOCOL_ANY
.Profiles = objNetFwPolicy2.CurrentProfileTypes
.Direction = NET_FW_RULE_DIR_OUT
.Action = NET_FW_ACTION_BLOCK
.Enabled = True
End With
objNetFwPolicy2.Rules.Add objNetFwRule2
Set objNetFwRule2 = Nothing
WScript.CreateObject("WScript.Shell").Run """" & strSourceFile & """", 1, True
For Each objNetFwRule2 In objNetFwPolicy2.Rules
If StrComp(objNetFwRule2.ApplicationName, strSourceFile, vbTextCompare) = 0 Then
objNetFwPolicy2.Rules.Remove objNetFwRule2.Name
End If
Next
WScript.Quit 0
?!
Кривовастенько, конечно, да…