• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    一步步做自己的webinstall安装包
    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.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 表示应用程序在进程内运行,值 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)”,添加完成后,在文件系统中右键应用程序文件夹设置默认安装目录。
    若还想去定义更多的用户安装数据,请增加用户界面。
    您可能感兴趣的文章:
    • 商店系统 V4.7 正式版安装包发布+免费商店 下载
    • 已证实Au_.exe是NSIS安装包的一个组成部分与说明
    • c#制作类似qq安装程序一样的单文件程序安装包
    • android实现程序自动升级到安装示例分享(下载android程序安装包)
    • 查看Python安装路径以及安装包路径小技巧
    • python学习之第三方包安装方法(两种方法)
    上一篇:在asp.net网页中显示数学符号的代码
    下一篇:ASP.NET Web页生命周期和执行的方法介绍
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    一步步做自己的webinstall安装包 一,步步,做,自己的,webinstall,