获取会话名称时的错误 1702
其中一种可能为 Terminal Services 被停用,
下面代码可显示此情形 并 解决 这种原因造成的报错- msg * MSG testing
- (sc query termservice | find "STOPPED") && (echo Terminal Services 未启用
- sc config TermService start= Auto
- sc start TermService
- ) || echo Terminal Services 已启用
- (sc query termservice | find "STOPPED") && (echo Terminal Services 未启用) || echo Terminal Services 已启用
- msg * MSG testing
- pause
复制代码 运行结果:D:\桌面>msg * MSG testing
获取会话名称时的错误 1702
D:\桌面>(sc query termservice | find "STOPPED" ) && (
echo Terminal Services 未启用
sc config TermService start= Auto
sc start TermService
) || echo Terminal Services 已启用
STATE : 1 STOPPED
Terminal Services 未启用
[SC] ChangeServiceConfig SUCCESS
SERVICE_NAME: TermService
TYPE : 20 WIN32_SHARE_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 1440
FLAGS :
D:\桌面>(sc query termservice | find "STOPPED" ) && (echo Terminal Services
未启用 ) || echo Terminal Services 已启用
Terminal Services 已启用
D:\桌面>msg * MSG testing
D:\桌面>pause
并成功显示对话框. |