我需要將可執行文件安裝爲服務,並且需要使用用C#編寫的PowerShell cdmlet來執行此操作。實質上,我需要創建所需的註冊表項等來定義服務(包括要運行的可執行文件 - 一種srvany.exe)。C#實現新服務cmdlet
我還需要能夠定義此服務的登錄身份(憑證)。
TIA,漢斯
有什麼我想這麼遠。我一直在尋找ServiceProcessInstaller和ServiceProcessInstaller類,但他們錯過了定義'external'可執行文件的可能性。
public partial class MyServiceInstaller : Installer
{
public MyServiceInstaller()
{
IDictionary saveState = null;
this.Installers.Clear();
ServiceProcessInstaller spi = new ServiceProcessInstaller();
ServiceInstaller si = new ServiceInstaller();
spi.Account = ServiceAccount.LocalSystem;
spi.Username = null;
spi.Password = null;
si.ServiceName = "MyService";
si.DisplayName = "MyService";
si.StartType = ServiceStartMode.Automatic;
si.Description = "MyService - I wish....";
spi.Installers.Add(si);
this.Installers.Add(spi);
this.Install(saveState);
}
}
被困在這裏,因爲我找不到添加可執行文件的路徑(服務的ImagePath)的方式
,而['你有什麼tried'(http://mattgemmell.com/2008/12/08/what-have-you-tried/)?你遇到過什麼特別的困難?我在你的問題中看到的所有內容都是'我需要...',但是我沒有看到'這是我嘗試的代碼,但是...' – 2013-02-14 17:33:31
歡迎來到SO。請查看[常見問題]和[關於]頁面,查看哪些問題最受歡迎。 – 2013-02-14 17:50:19