我用VS自带的打包程序来制作,打包没有问题,只是想在安装后,让安装程序自动运行一个EXE文件,请教如何设置????
解决方案 »
- 哥哥姐姐们有谁做过.net 下语音功能的项目么?
- javascrip能实现上传图片并把图片保存下来以供读取吗?
- WinForm添加Flash问题……&
- C# 备份sql服务器文件到本地
- 推荐一本 C# 或 .NET 网络Socket编程的书籍
- 多线程中,不同对象生成的线程如何能共享一个阻塞?
- 看《一步一步学习ASP.NET MVC 1.0》这本书后的一个问题
- C#中QQ的IP地址查询
- 当Session失效后自动跳转到登录页(不改动页面代码的条件下)
- 由于datetime.now.tostring()太多,想统一调用一个方法,结果IIS崩溃。。。
- 怎样通过 WMI,获取进程状态
- 高手进,控件数据绑定时list与datatable的选择
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
namespace ClassLibrary1
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
Process p = new Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = @"mybat.exe";
p.StartInfo.UseShellExecute = true;
p.Start();
p.WaitForExit();
p.Dispose(); base.Install(stateSaver); } }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
namespace ClassLibrary1
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{ base.Install(stateSaver); //调整后,这句放在了上面 Process p = new Process();
p.StartInfo.RedirectStandardOutput = false;
// p.StartInfo.FileName = @"mybat.exe";
p.StartInfo.FileName = @"C:\Program Files\营收系统\update.bat"; //这样只后到是能找到批处理文件了
p.StartInfo.UseShellExecute = true;
p.Start();
p.WaitForExit();
p.Dispose();
}
}
}
//这就是想实现运行这个批处理文件,现在使用绝对路径,能找到这个批处理文件,我想请教,如何直接定位于当前系统安装的路径,这个批处理就在项目所在的目录中。还有一点,虽然找到了这个批处理文件,也运行了,但是批处理中要执行的两个命令文件却找不到。如果直接手动运行这个批处理是没有问题的,下面是批处理的内容:
@ECHO OFFsn -Vr DevExpress.Data.v7.2.dll
gacutil /i DevExpress.Data.v7.2.dll
sn -Vr DevExpress.Utils.v7.2.dll
gacutil /i DevExpress.Utils.v7.2.dllpause
提示sn gacutil不是可用的内部命令,好像还是路径问题
给你个示例程序
提示'sn'不是内部或外部命令,也不是可运行的程序或批处理文件
'gacutil'不是内部或外部命令,也不是可运行的程序或批处理文件
以下是批处理的内容:@ECHO OFF sn -Vr DevExpress.Data.v7.2.dll
gacutil /i DevExpress.Data.v7.2.dll
sn -Vr DevExpress.Utils.v7.2.dll
gacutil /i DevExpress.Utils.v7.2.dll pause 请教如何处理
/// <summary>
/// 安装提交
/// </summary>
/// <param name="savedState"></param>
public override void Commit(System.Collections.IDictionary savedState)
{
try
{
base.Commit(savedState); Process pro = new Process();
pro.StartInfo.UseShellExecute = true;
pro.StartInfo.FileName = this.Context.Parameters["targetdir"].ToString() + "SetUp.exe";//要执行的文件路径
pro.StartInfo.CreateNoWindow = false;
pro.Start(); Thread.Sleep(2000);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}