Page 1 sur 1

[..] Ajouter / activer / désactiver les exceptions du pare-feu

Posté : sam. 09 mars 2019 11:38
par Boulanza
Bonjour tout le monde,
Voici le message d'erreur:
$Profile = $Policy.GetProfileByType(1)
$Profile = $Policy^ ERROR
Lorsque j'execute le le code ci-dessous.
Y a t'il un autr code AutoIt qui permet d'ajouter une exception pare feu windows 10
#RequireAdmin

;Add/Enable/Disable Firewall Exception
Func _FirewallException($_intEnableDisable, $_appName, $_applicationFullPath)
    $Firewall = ObjCreate("HNetCfg.FwMgr")
    $Policy = $Firewall.LocalPolicy
    $Profile = $Policy.GetProfileByType(1)
    $colApplications = $Profile.AuthorizedApplications
    $newApplication = ObjCreate("HNetCfg.FwAuthorizedApplication")
    $newApplication.Name = $_appName
    $newApplication.IpVersion = 2
    $newApplication.ProcessImageFileName = $_applicationFullPath
    $newApplication.RemoteAddresses = "*"
    $newApplication.Scope = 0
    $newApplication.Enabled = $_intEnableDisable
    $colApplications.Add($newApplication)
EndFunc   ;==>_FirewallException

;Example usage ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;Example block Autoit
;_FirewallException(0, "Autoit", @AutoItExe)

;Example allow Autoit
_FirewallException(1, "Autoit", @AutoItExe)
Merci pour votre aide.
Cordialement.