国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

一步步做自己的webinstall安裝包

2024-07-09 22:47:06
字體:
來源:轉載
供稿:網友
1、 為了能更好的操作IIS,先添加個類庫(InstallClassLibrary)到項目中。附代碼
代碼如下:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.DirectoryServices;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.AccessControl;
using System.IO;
namespace InstallClassLibrary
{
[RunInstaller(true)]
public partial class WebInstaller : Installer
{
public WebInstaller()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
CreateVirtualDir();//以下代碼為更改網站指定目錄權限
DirectoryInfo di = new DirectoryInfo("d://yourpath//xml");
if((di.Attributes&FileAttributes.ReadOnly)!=0)
di.Attributes=FileAttributes.Normal;
DirectorySecurity ds=di.GetAccessControl();
ds.AddAccessRule(new FileSystemAccessRule("NETWORK SERVICE",FileSystemRights.Modify,InheritanceFlags.ObjectInherit|InheritanceFlags.ContainerInherit,
PropagationFlags.None,AccessControlType.Allow));
di.SetAccessControl(ds);
//
}
void CreateVirtualDir()
{
try
{
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/1/root");
DirectoryEntry newRoot = root.Children.Add("virtualName", root.SchemaClassName);
newRoot.Properties["Path"][0] = "d://yourpath"; //this.Context.Parameters["targetdir"];
newRoot.Properties["AppIsolated"][0] = 2; // 值 0 表示應用程序在進程內運行,值 1 表示進程外,值 2 表示進程池
newRoot.Properties["AccessScript"][0] = true; // 可執行腳本
newRoot.Invoke("AppCreate", true);
newRoot.Properties["DefaultDoc"][0] = "login.aspx";//設置起始頁
newRoot.Properties["AppFriendlyName"][0] = "applicationName"; // 應用程序名
newRoot.CommitChanges();
root.CommitChanges();
}
catch (Exception ee)
{
MessageBox.Show("虛擬目錄創建失敗!您可以手動創建! " + ee.Message + ";" + ee.Source + ";" + ee.TargetSite + ";" + ee.InnerException + ";" + ee.StackTrace, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
}
}
}

2、添加安裝項目到解決方案中,然后在該安裝項目(Setup)中添加-項目輸出,把WEB內容和剛才建立的類庫添加到目錄中。
3、在安裝項目左鍵在屬性窗口中更改制造商,安裝程序的標題、是否針對所有用戶安裝、產品名等內容。
右鍵-視圖-自定義操作,右鍵安裝-添加自定義操作-應用程序文件夾,選擇“安裝類庫(InstallClassLibrary)”,添加完成后,在文件系統中右鍵應用程序文件夾設置默認安裝目錄。
若還想去定義更多的用戶安裝數據,請增加用戶界面。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和硕县| 保靖县| 东乡县| 绥中县| 洱源县| 望城县| 普兰县| 西藏| 许昌县| 卓尼县| 江阴市| 嘉禾县| 美姑县| 高陵县| 乐亭县| 班玛县| 丁青县| 仲巴县| 常熟市| 屏边| 壤塘县| 东至县| 嘉义县| 珠海市| 云安县| 邵阳县| 安远县| 周至县| 绍兴市| 闽清县| 荣成市| 沾化县| 恩平市| 汉川市| 汨罗市| 湖北省| 苏尼特右旗| 宜州市| 美姑县| 南华县| 读书|