自动更新程序已经写好(Update.exe),当程序运行的时候自动更新,现在手动更新(双击Update.exe)可以实现更新,但是上级要求必须在凌晨1点钟的时候启用一次更新,所以写了一个WindowsService服务,在监听函数里面写入:if (DateTime.Now.Hour.ToString() =="0")
            {
                FunctionLibrary = new AssistantFunctionLibrary();
                FunctionLibrary.RegisterActionInf("采集更新开始!");                      Process.Start(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Update.exe");
            }
服务的:"允许服务与桌面交互"已开启,但是未能实现预期的目的,请问是什么原因造成的?进程WindowsService服务更新

解决方案 »

  1.   

    Win service 启动程序是没问题的,但程序的UI是不会显示在当前login用户的桌面的,
    因为不是一个session。所以要保证你的程序能自己运行就好,没有UI可以写LOG文件看过程。
      

  2.   

    http://blog.csdn.net/lanruoshui/article/details/4968901
      

  3.   


    交互已经完成了,但是实现不了程序(Update.exe)的功能~求指教
      

  4.   


    交互已经完成了,但是实现不了程序(Update.exe)的功能~求指教
    直接启动 Update.exe 不就行了?   ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.FileName =path+@"\Update.exe";
                        startInfo.WindowStyle = ProcessWindowStyle.Normal;
                        Process.Start(startInfo);
                        Process.GetCurrentProcess().Kill();
      

  5.   


    交互已经完成了,但是实现不了程序(Update.exe)的功能~求指教
    直接启动 Update.exe 不就行了?   ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.FileName =path+@"\Update.exe";
                        startInfo.WindowStyle = ProcessWindowStyle.Normal;
                        Process.Start(startInfo);
                        Process.GetCurrentProcess().Kill();
    现在程序是运行出来了,但是里面的具体操作没出来啊?
    XmlDocument xdConfig = new XmlDocument();
    string strAppPath = AppDomain.CurrentDomain.BaseDirectory;
    xdConfig.Load(strAppPath + "CourtInteTIM.ElisorEesWhs.config");   //XML地址
    XmlElement xnode = (XmlElement)xdConfig.SelectSingleNode("/configuration/UpdateImformation");
    DownLoadNewFile("UpdateConfiguration.xml");
    XmlDocument xdRead = new XmlDocument();
    xdRead.Load(strAppPath + "\\UpdateConfiguration.xml");
    XmlNodeList xnlNode = xdRead.GetElementsByTagName("add");
    string strDate = xnlNode[0].Attributes["updateDate"].Value;
    if (strDate != xnode.GetAttribute("UpdateTime"))
    {
        for (int i = 1; i < xnlNode.Count; i++)
        {
             string strUpdateFile = xnlNode[i].Attributes["fileName"].Value;
             DownLoadNewFile(strUpdateFile);
        }
        xnode.SetAttribute("UpdateTime", strDate);
        xdConfig.Save(strAppPath + "CourtInteTIM.ElisorEesWhs.config");
    }
    是AppDomain.CurrentDomain.BaseDirectory;获取有错误吗?最后一步了,求指教啊~~
      

  6.   

    到最后只是工作路径的问题啊ProcessStart() 用ProcessStartInfo做参数,
    可以设定工作路径:ps.WorkingDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
      

  7.   

    养成好习惯,关键步骤写log文件来检查后台程序是否工作正常。