nwcs wrote:
請問是WINRAR...(恕刪)
nwcs 您好:
因為是 windows 服務,它沒有任何訊息,但從右下角工作列來看是沒有執行的....
我又獨立把 winrar 抓出來做主控台應用程式,它是可以正常在xp下執行壓縮winrar
但放到windows 服務,現在是出現...
C:\>InstallUtil /i .\WindowsService2.exe
Microsoft (R) .NET Framework Installation Utility Version 4.0.30319.33440
Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。
正在執行交易性的安裝。
正在開始安裝程式的安裝階段。
請參閱 C:\WindowsService2.exe 組件進度的記錄檔內容。
檔案是位於 C:\WindowsService2.InstallLog。
正在安裝組件 'C:\WindowsService2.exe'。
受影響的參數為:
i =
logfile = C:\WindowsService2.InstallLog
assemblypath = C:\WindowsService2.exe
logtoconsole =
正在安裝服務 Service1...
正在記錄檔 Application 中建立 EventLog 來源 Service1...
安裝階段中發生例外狀況。
System.ComponentModel.Win32Exception: 指定的服務已存在。
正在開始安裝的復原階段。
請參閱 C:\WindowsService2.exe 組件進度的記錄檔內容。
檔案是位於 C:\WindowsService2.InstallLog。
正在復原組件 'C:\WindowsService2.exe'。
受影響的參數為:
i =
logfile = C:\WindowsService2.InstallLog
assemblypath = C:\WindowsService2.exe
logtoconsole =
正將來源 Service1 的事件記錄檔恢復成之前的狀態。
已經成功完成復原階段。
已經完成交易性的安裝。
安裝已經失敗,並且已經執行復原。
C:\>net start WindowsService2.exe
服務名稱無效。
---------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Win32;
using System.Timers;
using System.Collections;
using System.Net;
namespace WindowsService2
{
public partial class Service1 : ServiceBase
{
private Timer MyTimer;
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
MyTimer = new Timer();
MyTimer.Elapsed += new ElapsedEventHandler(MyTimer_Elapsed);
MyTimer.Interval = 10* 60 * 1000; // 10min
MyTimer.Start();
}
private void MyTimer_Elapsed(object sender, ElapsedEventArgs e)
{
Process o = new Process();
o.StartInfo.FileName = @"C:\Program Files\WinRAR\WinRAR.exe";
o.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
o.StartInfo.Arguments = @"a c:\vba d:\vbe\tmp\*.*";
o.Start();
}
protected override void OnStop()
{
}
}
}
--------------------------------
真是搞得快頭昏了...
看到
安裝階段中發生例外狀況。
System.ComponentModel.Win32Exception: 指定的服務已存在。
但在工作管理員裡的服務是沒有 windowsService2
所以還是下uninstallutil /u windowsService2 把它解除安裝,還真的可以解除安裝....
所以又下 installutil /i windowsService2,可是安裝ok,但沒辦法啟動?
C:\>installutil /u .\WindowsService2.exe
Microsoft (R) .NET Framework Installation Utility Version 4.0.30319.33440
Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。
正開始解除安裝。
請參閱 C:\WindowsService2.exe 組件進度的記錄檔內容。
檔案是位於 C:\WindowsService2.InstallLog。
正在解除安裝組件 'C:\WindowsService2.exe'。
受影響的參數為:
logtoconsole =
logfile = C:\WindowsService2.InstallLog
assemblypath = C:\WindowsService2.exe
正在移除 EventLog 來源 Service1。
警告: 來源 Service1 未於本機電腦上註冊。
已從系統中移除服務 Service1...
在 System.ServiceProcess.ServiceInstaller 安裝程式的解除安裝中發生例外狀況。
System.ComponentModel.Win32Exception: 指定的服務並不是已安裝的服務。
解除安裝時發生例外狀況。將略過此例外狀況,而解除安裝將會繼續。然而,解除安裝完成
之後,可能無法完全解除安裝應用程式。
已經完成解除安裝。
解除安裝時發生例外狀況。將略過此例外狀況,而解除安裝將會繼續。然而,解除安裝完成
之後,可能無法完全解除安裝應用程式。
C:\>InstallUtil /i .\WindowsService2.exe
Microsoft (R) .NET Framework Installation Utility Version 4.0.30319.33440
Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。
正在執行交易性的安裝。
正在開始安裝程式的安裝階段。
請參閱 C:\WindowsService2.exe 組件進度的記錄檔內容。
檔案是位於 C:\WindowsService2.InstallLog。
正在安裝組件 'C:\WindowsService2.exe'。
受影響的參數為:
i =
logfile = C:\WindowsService2.InstallLog
assemblypath = C:\WindowsService2.exe
logtoconsole =
正在安裝服務 Service1...
已經成功安裝服務 Service1。
正在記錄檔 Application 中建立 EventLog 來源 Service1...
安裝階段已經成功完成,正在開始認可階段。
請參閱 C:\WindowsService2.exe 組件進度的記錄檔內容。
檔案是位於 C:\WindowsService2.InstallLog。
正在認可組件 'C:\WindowsService2.exe'。
受影響的參數為:
i =
logfile = C:\WindowsService2.InstallLog
assemblypath = C:\WindowsService2.exe
logtoconsole =
已經成功完成認可階段。
已經完成交易性的安裝。
C:\>net start WindowsService2
服務名稱無效。




























































































