1) There is a commandline tool (installed when the framework is installed) 'caspol.exe' which does exactly the same as the wizard.
This tool is in the folder %windir%\Microsoft.NET\Framework\your latest framework version (eg. v1.1.4322)
2) The following excerpt adjust security from code:
DimmachinePolicyLevel As PolicyLevel = Nothing
Dim ph As IEnumerator = SecurityManager.PolicyHierarchy
Do While ph.MoveNext
Dim p1 As PolicyLevel = CType(ph.Current, PolicyLevel)
If p1.Label = "Machine" Then
machinePolicyLevel = p1
Exit Do
End If
Loop
If machinePolicyLevel Is Nothing Then Return
' Intranet
Dim permissionSet As PermissionSet = New NamedPermissionSet("FullTrust")
Dim membership As IMembershipCondition = New UrlMembershipCondition("http://<some ip address>/<some directory>/*")
Dim policy As PolicyStatement = New PolicyStatement(permissionSet)
Dim codeGroup As CodeGroup = New UnionCodeGroup(membership, policy)
codeGroup.Description = "FullTrust permissions for http://<some ip address>/<some directory>/"
codeGroup.Name = "XXX"
' Internet
Dim permissionSet2 As PermissionSet = New NamedPermissionSet("FullTrust")
Dim membership2 As IMembershipCondition = New UrlMembershipCondition("http://<some ip address>/<some directory>/*")
Dim policy2 As PolicyStatement = New PolicyStatement(permissionSet2)
Dim codeGroup2 As CodeGroup = New UnionCodeGroup(membership2, policy2)
codeGroup2.Description = "FullTrust permissions for http://<some ip address>/<some directory>/"
codeGroup2.Name = "XXX"
machinePolicyLevel.RootCodeGroup.AddChild(codeGroup)
machinePolicyLevel.RootCodeGroup.AddChild(codeGroup2)
SecurityManager.SavePolicy()