我剛剛建立了一個簡單的Windows服務時遇到麻煩就開始錯誤:2未找到文件 - Windows服務
The Commit phase completed successfully.
The transacted install has completed.
M:\MyDocuments\Visual Studio 2013\Projects\WindowsService1\WindowsService1\bin\Debug>Net start WindowsService1.exe
System error 2 has occurred.
The system cannot find the file specified.
是映射的網絡驅動器上,我有服務的代碼帳戶設置爲
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
這是某種權限問題嗎?是否有任何工具或實用程序來診斷這種問題?
更新:該代碼是一個空的服務
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
}
protected override void OnStop()
{
}
}
}
更新2:該錯誤是當我啓動該服務,而不是當我安裝它。我成功地
M:\MyDocuments\Visual Studio 2013\Projects\WindowsService1\WindowsService1\bin\Debug>installutil WindowsService1.exe
這可能是一個權限問題,但沒有代碼很難說。 – Rafa
您需要首先安裝(註冊)服務(請參閱有關sc.exe的幫助,該命令行程序允許您與服務控制器進行交互),然後使用net start和net stop來控制它(或使用'sc start'和'sc stop')。大多數服務也接受一個'/ install'命令行開關,它爲你註冊Windows。 –