佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > 一步步做自己的webinstall安裝包

一步步做自己的webinstall安裝包

熱門標(biāo)簽:阿里云 Linux服務(wù)器 科大訊飛語音識(shí)別系統(tǒng) Mysql連接數(shù)設(shè)置 服務(wù)器配置 銀行業(yè)務(wù) 團(tuán)購網(wǎng)站 電子圍欄
1、 為了能更好的操作IIS,先添加個(gè)類庫(InstallClassLibrary)到項(xiàng)目中。附代碼
復(fù)制代碼 代碼如下:

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();//以下代碼為更改網(wǎng)站指定目錄權(quán)限
DirectoryInfo di = new DirectoryInfo("d:\\yourpath\\xml");
if((di.AttributesFileAttributes.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 表示應(yīng)用程序在進(jìn)程內(nèi)運(yùn)行,值 1 表示進(jìn)程外,值 2 表示進(jìn)程池
newRoot.Properties["AccessScript"][0] = true; // 可執(zhí)行腳本
newRoot.Invoke("AppCreate", true);
newRoot.Properties["DefaultDoc"][0] = "login.aspx";//設(shè)置起始頁
newRoot.Properties["AppFriendlyName"][0] = "applicationName"; // 應(yīng)用程序名
newRoot.CommitChanges();
root.CommitChanges();
}
catch (Exception ee)
{
MessageBox.Show("虛擬目錄創(chuàng)建失??!您可以手動(dòng)創(chuàng)建! " + ee.Message + ";" + ee.Source + ";" + ee.TargetSite + ";" + ee.InnerException + ";" + ee.StackTrace, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
}
}
}

2、添加安裝項(xiàng)目到解決方案中,然后在該安裝項(xiàng)目(Setup)中添加-項(xiàng)目輸出,把WEB內(nèi)容和剛才建立的類庫添加到目錄中。
3、在安裝項(xiàng)目左鍵在屬性窗口中更改制造商,安裝程序的標(biāo)題、是否針對所有用戶安裝、產(chǎn)品名等內(nèi)容。
右鍵-視圖-自定義操作,右鍵安裝-添加自定義操作-應(yīng)用程序文件夾,選擇“安裝類庫(InstallClassLibrary)”,添加完成后,在文件系統(tǒng)中右鍵應(yīng)用程序文件夾設(shè)置默認(rèn)安裝目錄。
若還想去定義更多的用戶安裝數(shù)據(jù),請?jiān)黾佑脩艚缑妗?
您可能感興趣的文章:
  • 商店系統(tǒng) V4.7 正式版安裝包發(fā)布+免費(fèi)商店 下載
  • 已證實(shí)Au_.exe是NSIS安裝包的一個(gè)組成部分與說明
  • c#制作類似qq安裝程序一樣的單文件程序安裝包
  • android實(shí)現(xiàn)程序自動(dòng)升級到安裝示例分享(下載android程序安裝包)
  • 查看Python安裝路徑以及安裝包路徑小技巧
  • python學(xué)習(xí)之第三方包安裝方法(兩種方法)

標(biāo)簽:棗莊 衡水 江蘇 萍鄉(xiāng) 蚌埠 衢州 廣元 大理

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《一步步做自己的webinstall安裝包》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    体育| 东兰县| 宜川县| 沿河| 措美县| 富宁县| 谢通门县| 威海市| 定西市| 马尔康县| 仪陇县| 罗城| 吉木萨尔县| 文山县| 宝坻区| 颍上县| 晋中市| 临邑县| 浦县| 克东县| 青河县| 集贤县| 闵行区| 抚顺市| 鹤庆县| 达州市| 夏河县| 绥芬河市| 台江县| 东乡| 南京市| 铁岭市| 罗源县| 丰原市| 雅安市| 饶阳县| 石城县| 汾阳市| 井研县| 沙田区| 雅江县|