sc.exe因1639失败

amb*_*ber 2 command-line windows-services windows-server-2008-r2

我们正在建立一个新的环境,我正在编写批处理文件,以便在群集中的多台计算机上使用.一致性是我的朋友.:)

命令行只列出参数并设置errorlevel = 1639.

    d:\services\WFCContainerStatus>sc config ContainerStatusService start=auto
DESCRIPTION:
        Modifies a service entry in the registry and Service Database.
USAGE:
        sc <server> config [service name] <option1> <option2>...

OPTIONS:
NOTE: The option name includes the equal sign.
      A space is required between the equal sign and the value.
 type= <own|share|interact|kernel|filesys|rec|adapt>
 start= <boot|system|auto|demand|disabled|delayed-auto>
 error= <normal|severe|critical|ignore>
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
 DisplayName= <display name>
 password= <password>

d:\services\WFCContainerStatus>echo %errorlevel%
1639
Run Code Online (Sandbox Code Playgroud)

查找错误代码至少可以说是一种尝试经验.尝试net helpmsg就像usefil一样.

d:\services\WFCContainerStatus>net helpmsg 1639

Invalid command line argument. Consult the Windows Installer SDK for detailed command line help.
Run Code Online (Sandbox Code Playgroud)

我确信这是微不足道的,我做错了,我只是没有看到它.

有没有人对此有任何想法?

amb*_*ber 5

显然,我需要学会阅读,因为我的答案就在我面前.

d:\services\WFCContainerStatus>sc config ContainerStatusService start= auto
[SC] ChangeServiceConfig SUCCESS
Run Code Online (Sandbox Code Playgroud)

正如帮助文本所说,"等号和值之间需要一个空格".添加空间,一切正常.

  • 疯狂的!我自己就遇到了这个。看来 Windows 10 和 Server 2019(也许 2016 年)不需要该空间,但 Windows 7 需要(猜测 Server 2008 也一样)。尽管这些现已不再支持,但对于付费的 Pro/Enterprise 批量用户的扩展安全更新仍然有效(直到 2023 年)。 (2认同)