2009-07-21 90 views

回答

26

您可以使用SC命令。

sc.exe \\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe start= auto obj= DOMAIN\username password= pwd

(注意空格等於後標誌是重要的)

Creates a service entry in the registry and Service Database. 
SYNTAX: 
sc create [service name] [binPath= ] <option1> <option2>... 
CREATE OPTIONS: 
NOTE: The option name includes the equal sign. 
type= <own|share|interact|kernel|filesys|rec> 
     (default = own) 
start= <boot|system|auto|demand|disabled> 
     (default = demand) 
error= <normal|severe|critical|ignore> 
     (default = normal) 
binPath= <BinaryPathName> 
group= <LoadOrderGroup> 
tag= <yes|no> 
depend= <Dependencies(separated by/(forward slash))> 
obj= <AccountName|ObjectName> 
     (default = LocalSystem) 
DisplayName= <display name> 
password= <password> 
+0

看起來很有前途,但是我必須付錢嗎? – Grzenio 2009-07-21 13:28:19

+0

它包含在Windows中,可能在資源工具包中,啓動命令提示符並鍵入sc以查看它是否已安裝。 – 2009-07-21 13:47:36

1

從Powershell調用的WMI中調用的Installutil是一種可行的方法。

0

我們習慣用PsExec做遠程機器上的一切。 在這個時候我看到了叫做PowerShell Remoting的naother解決方案,但還沒有嘗試過自己。

0

這可能是值得您檢查一下我寫的一個實用程序,它允許您在本地或遠程計算機上安裝/卸載/啓動/停止Windows服務。如果你有需要添加的功能,讓我知道(評論/ github問題或PM,我會很樂意)。

ServiceConfigurator on GitHub

由於@Raj更多建議,它使用WMI從.NET調用。

相關問題