
Работает только с Microsoft FireWall, запускать с учётки юзера с правами админа
War3FW.vbs
- Код: Выделить всё
Option Explicit
Dim fwMgr,fso,ImageFileName,profile,app,War3
On Error Resume Next
Set fso=CreateObject("Scripting.FileSystemObject")
if NOT fso.FileExists("War3.exe") then
Wscript.Echo "War3.exe not found"
WScript.Quit
end if
ImageFileName=fso.GetAbsolutePathName(".") & "\War3.exe"
Set fwMgr=CreateObject("HNetCfg.FwMgr")
if Err.Number<>0 then
Wscript.Echo "Can't create FwMgr"
WScript.Quit
end if
Set profile=fwMgr.LocalPolicy.CurrentProfile
if Err.Number<>0 then
Wscript.Echo "Can't open CurrentProfile"
WScript.Quit
end if
War3=False
For Each app In profile.AuthorizedApplications
if LCase(app.ProcessImageFileName)=LCase(ImageFileName) then
if app.Enabled then
WScript.Echo "WarCraft exception already added and enabled"
else
app.Enabled = True
if Err.Number<>0 then
WScript.Echo "Can't enable WarCraft exception"
else
WScript.Echo "WarCraft exception enabled"
end if
end if
War3=True
exit for
end if
Next
if NOT War3 then
Set app=CreateObject("HNetCfg.FwAuthorizedApplication")
if Err.Number<>0 then
Wscript.Echo "Can't open AutorizedApplication"
WScript.Quit
end if
app.ProcessImageFileName=ImageFileName
app.Name="WarCraft III"
app.Scope=0
app.IpVersion=2
app.Enabled=True
profile.AuthorizedApplications.Add app
if Err.Number<>0 then
Wscript.Echo "Failed adding WarCraft III to FireWall exceptions"
else
Wscript.Echo "Adding WarCraft III to FireWall exceptions"
end if
end if
WScript.Quit