System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article describes how to create a Microsoft Windows Installer package that uses the Code Access Security Policy tool in Microsoft Visual Studio 2005.
You can use the Code Access Security Policy tool to modify the security policy for the following policy levels:
The Machine policy level
The User policy level
The Enterprise policy level
You can use the Microsoft .NET Framework 2.0 Configuration tool to create a Windows Installer package that modifies the security policy. To do this, follow these steps:
Click Start, click Run, type Control admintools in the Open box, and then click OK.
In Administrative Tools, double-click Microsoft .NET Framework 2.0 Configuration.
In the .NET Framework 2.0 Configuration dialog box, expand My Computer, click Runtime Security Policy, and then click Create Deployment Package.
When you follow these steps, the whole policy level is replaced.
To make a specific change to the security policy and to avoid overwriting other policies, follow these steps.
Step 2: Use Visual Studio 2005 to create a base Windows Installer package
To create a base Windows Installer package, follow these steps:
Start Visual Studio 2005.
On the File menu, click New, and then click Project.
In the New Project dialog box, expand Other Project Types under Project Types, click Setup and Deployment, and then click Setup Project under Visual Studio installed templates.
In the Name box, type Caspol.msi.
In the Location box, type the location of the Caspol.msi file, and then click OK.
On the View menu, click Editor, and then click Launch Conditions.
On the Launch Conditions tab, right-click Search Target Machine under Requirements on Target Machine, and then click Add File Search.
For the name of the new node, type Caspol-search.
Right-click Caspol-search, and then click Properties Windows.
In the Caspol-search Launch Condition Properties dialog box, specify the following values:
In the Depth box, type 10.
In the FilesName box, type caspol.exe.
In the Folder box, click [WindowsFolder].
In the MinVersion box, type 2.0.
Note This setting is required so that the destination computer does not use a version of the .NET Framework that is earlier than this setting.
Typically, you have a project in a solution to which you can add the base Windows Installer package that you created. If you do not have a project, you must sign the assembly. To do this, follow these steps:
Start Visual Studio 2005.
On the File menu, click Add, and then click New Project.
In the Add New Project dialog box, expand Visual C#, click Windows, and then click Windows Application under Visual Studio installed templates.
In the Name box, type a name.
In the Location box, type the location, and then click OK.
To sign the assembly by using a new key file, right-click WindowsApplication1
in Solution Explorer, and then click Properties.
On the WindowsApplication1 tab, click Signing.
Click to select the Sign the assembly check box.
To specify a new key file, click <New> in the Choose a strong name key file list.
Note New key files are always created in the .pfx format.
In the Create Strong Name Key dialog box, type a name, type a password, and then click OK.
Step 3: Use the Orca tool (Orca.exe) to add custom actions
Note This section assumes that the Orca tool is installed. For more information about the Orca tool, see the "References" section.
To use the Orca tool to add custom actions, follow these steps:
In Microsoft Windows Explorer, locate the Caspol.msi file, right-click the Caspol.msi file, and then click Edit with Orca.
In the Orca tool, click CustomAction under Tables, click the Tables menu, and then click Add Row.
In the Add Row dialog box, specify the following values:
In the Name column, click Action, and then type CASPOLTURNOFFMESSAGES in the Action box under Column.
In the Name column, click Type, and then type 3122 in the Type box under Column.
In the Name column, click Source, and then type FILEEXISTS1 in the Source box under Column.
In the Name column, click Target, and then type -pp off in the Target box under Column.
To close the Add Row dialog box, click OK.
In the Orca tool, click CustomAction under Tables, click the Tables menu, and then click Add Row.
In the Add Row dialog box, specify the following values:
In the Name column, click Action, and then type CASPOLPERFORMACTION in the Action box under Column.
In the Name column, click Type, and then type 3122 in the Type box under Column.
In the Name column, click Source, and then type FILEEXISTS1 in the Source box under Column.
In the Name column, click Target, and then type the following command in the Target box under Column:
-addgroup 1 -strong -file "[TARGETDIR]MyNewCaspolTest.exe" MyReferenceAssemblyName -noversion Execution -name MyCaspolCodeGroupName -description "This Code group was added by the caspol command line from our test Windows Installer package."
Note The prefixed [TARGETDIR] property and the .exe file name are enclosed by quotation marks. The prefixed [TARGETDIR] property and the .exe file name do not have a backslash (\). For more information about the options for the Code Access Security Policy tool, visit the following Microsoft Developer Network (MSDN) Web site:
Note The command options are case sensitive. Use the ALLUSERS=2 option to install the file on an individual computer. The /passive option requires minimal user input.
To confirm the settings that the Caspol.msi file modified, follow these steps:
Click Start, click Run, type Control admintools in the Open box, and then click OK.
In Administrative Tools, double-click Microsoft .NET Framework 2.0 Configuration.
In the .NET Framework 2.0 Configuration dialog box, expand My Computer, and then expand Runtime Security Policy.
Expand Machine, expand Code Groups, and then expand All_Code.
Right-click LocalIntranet_Zone, and then click Properties.
In the LocalIntranet_Zone Properties dialog box, click the Permission Set tab. Notice that Nothing is displayed under Permission set.
To uninstall the Caspol.msi file, right-click Caspol.msi, and then click Uninstall. To confirm that the Caspol.msi file is uninstalled, follow these steps:
Click Start, click Run, type Control admintools in the Open box, and then click OK.
In Administrative Tools, double-click Microsoft .NET Framework 2.0 Configuration.
In the .NET Framework 2.0 Configuration dialog box, expand My Computer, and then expand Runtime Security Policy.
Expand Machine, expand Code Groups, and then expand All_Code.
Right-click LocalIntranet_Zone, and then click Properties.
In the LocalIntranet_Zone Properties dialog box, click the Permission Set tab. Notice that LocalIntranet is displayed under Permission set.
The Orca tool is part of the Microsoft Windows Server 2003 Service Pack 1 (SP1) Platform Software Development Kit (SDK). For more information about the Windows Server 2003 SP1 Platform SDK, visit the following Microsoft Web site: