我在.net中创建了.exe并希望用作服务,在我的本地计算机上运行.我正在使用Windows Server 2012.如何在我的本地计算机上设置服务.
**您可以使用Windows shell脚本通过命令创建服务**
sc create命令执行CreateService API函数的操作.
这是做什么的......
将"yourapplication.exe"复制到Win2012服务器上的合适位置(例如C:\ Windows\System32 \).
使用"sc"创建一个启动"srvany"的新服务(例如sc create"Servicename"binPath ="C:'Windows'System32'srvany.exe"DisplayName ="My Custom Service")
使用RegEdit:为您的服务创建"参数"键(例如HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Servicename\Paramaters)
使用RegEdit:在新创建的"Parameters"键中,创建一个名为"Application"的字符串值,并输入要作为服务运行的应用程序的完整路径.(不需要引号.)
句法:-
sc [] create [] [type = {own | 分享| 内核| filesys | rec | interaction type = {own | 分享}}] [start = {boot | 系统| 汽车| 需求| 已禁用}] [error = {normal | 严重| 关键| ignore}] [binpath =] [group =] [tag = {yes | no}] [depend =] [obj = {| }] [displayname =] [password =]