如果服务处于手动模式,则.vbs文件不应启动该服务

时间:2015-10-15 14:40:12

标签: web-services batch-file

请查找以下WebStart.cmd代码:

当然,代码正在启动服务NetworkRequestWorkflow。但在未来的操作模式下,此服务将设置为手动模式,而.vbs不应自动启动此服务。请帮助我按预期完成任务。

setlocal
set LogDir="D:\Program Files (x86)\Bell\NetReq\Data\WebStartup.log"
PROMPT $P $D $T $G

REM Make sure that the services is set to automatic before doing iisreset   /start
@echo . >> %LogDir%

sc config msftpsvc start= auto >> %LogDir%
sc config smtpsvc start= auto >> %LogDir%
sc config w3svc start= auto >> %LogDir%

echo Start Web Server and related process > %LogDir%
PROMPT >> %LogDir%

iisreset /start /rebootonerror  >> %LogDir%
iisreset /status >> %LogDir%

REM added as part of NETREQ Upgrade Phase-1 project
echo Start NetReq Workflow Service > %LogDir%
@echo Environment - %COMPUTERNAME% >> %LogDir%
NET START "NetworkRequestWorkFlow" >> %LogDir%
NET START  >> %LogDir%
@echo . >> %LogDir%

endlocal

1 个答案:

答案 0 :(得分:1)

使用sc qc查询服务配置并将其传递给find以按"DEMAND_START"进行过滤:

sc qc NetworkRequestWorkflow | find "DEMAND_START">nul
if not errorlevel 1 (
    echo The service is in MANUAL start mode
    ...............
    ...............
) else (
    sc start NetworkRequestWorkflow
    ...............
    ...............
)