我使用Windows SC.exe和this创建了一个Windows服务,我面临以下问题:
关于第一点,我猜它与working directory
有关,因为我没有设置相同的工作目录,应用程序需要一些依赖于exe文件本身的依赖文件。
答案 0 :(得分:1)
服务的工作目录始终是System32。这是不可配置的。您需要确保能够加载System32中不属于该服务的任何依赖项。对于静态依赖项,通常只需在系统事件日志(eventvwr.msc)中查找错误记录即可。如果您发布了有关哪种依赖项(例如托管/非托管/运行时)的更多详细信息,我将能够提供更具体的解决方案。
服务的恢复选项可使用sc.exe进行配置:
c:\>sc failure /?
DESCRIPTION:
Changes the actions upon failure
USAGE:
sc <server> failure [service name] <option1> <option2>...
OPTIONS:
reset= <Length of period of no failures (in seconds)
after which to reset the failure count to 0 (may be INFINITE)>
(Must be used in conjunction with actions= )
reboot= <Message broadcast before rebooting on failure>
command= <Command line to be run on failure>
actions= <Failure actions and their delay time (in milliseconds),
separated by / (forward slash) -- e.g., run/5000/reboot/800
Valid actions are <run|restart|reboot> >
(Must be used in conjunction with the reset= option)