java.util. 无法引入:如何创建用户定义的服务

来源:百度文库 编辑:偶看新闻 时间:2024/04/28 04:34:19
在 Windows NT 资源工具包提供了两个实用程序,您可以创建一个 Windows NT 用户定义的服务的 Windows NT 应用程序和某些 16 位应用程序 (而不是批处理文件)。

To create a Windows NT user-defined service, perform the following steps:
  1. At a MS-DOS command prompt(running CMD.EXE), type the following command:

    path\INSTSRV.EXE My Service path\SRVANY.EXE

    where path is the drive and directory of the Windows NT Resource Kit (i.e., C:\RESKIT) and My Service is the name of the service you are creating.

    Example:C:\Program Files\Resource Kit\Instsrv.exe Notepad C:\Program Files\Resource Kit\Srvany.exeNOTE: To verify that the service was created correctly, check the registry to verify that the ImagePath value under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name is set to point to SRVANY.EXE. If this is not set correctly, the service will stop shortly after it starts and return an Event ID 7000 "The service name failed to start."

    WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

    For information about how to edit the registry, view the "Changing Keys And Values" online Help topic or the "Add and Delete Information in the Registry" and "Edit Registry Data" online Help topics in Registry Editor.

    NOTE: You should back up the registry before you edit it.
  2. Run Registry Editor (Regedt32.exe)and locate the following subkey:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
  3. From the Edit menu, click Add Key. Type the following and click OK:

    Key Name: Parameters
    Class :
  4. Select the Parameters key.
  5. From the Edit menu, click Add Value. Type the following and click OK:

    Value Name: Application
    Data Type : REG_SZ
    String : \

    where \ is the drive and full path to the application executable including the extension (i.e., C:\WinNT\Notepad.exe)
  6. Close Registry Editor.
By default, a newly created service it configured to run Automatically whenthe system is restarted. To change this setting to Manual, run the Servicesapplet from Control Panel and change the Startup value to Manual. A serviceset to Manual can be started in one of several ways:
- From the Services applet in Control Panel

- From a MS-DOS command prompt, type the following:

NET START

- Use the Sc.exe utility from the Resource Kit. Type the following from a MS-DOS command prompt:

\Sc.exe start

where is the drive and directory of the Windows NT Resource Kit (i.e., C:\Reskit).

For more information on installing and removing a user-defined service,please see the Srvany.wri document provided with the Windows NT ResourceKit utilities (i.e., C:\Reskit\Srvany.wri). This document can also be foundon the Windows NT Resource Kit CD in the Common\Config directory.
APPLIES TO
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows NT Workstation 3.51
  • Microsoft Windows NT Workstation 4.0 Developer Edition
  • Microsoft Windows NT Server 3.51
  • Microsoft Windows NT Server 4.0 Standard Edition
Back to the top

_______________________________________________________

若要进行 Windows NT 用户定义的服务执行以下步骤:
  1. 在 MS-DOS 命令提示符处 (运行 CMD.EXE),键入以下命令:

    path\INSTSRV.EXE My Service path \SRVANY.EXE

    path 所在的驱动器和目录的 Windows NT 资源工具包 (即,C:\RESKIT) 和 My Service 是您正在创建的服务的名称。

    示例:是 Files\Resource Kit\Instsrv.exe 记事本是 Files\Resource Kit\Srvany.exe注:若要验证该服务已正确创建,检查注册表,以验证下的 ImagePath 值 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ service name设置为指向 SRVANY.EXE。 如果这未正确设置,服务将停止不久之后它将启动并返回一个事件 ID 7000 service name 启动失败。

    警告:注册表编辑器使用不当会导致严重的问题,可能会要求您重新安装操作系统。Microsoft 不能保证可以解决导致错误地使用注册表编辑器的问题。使用注册表编辑器需要您自担风险。

    有关如何编辑注册表的信息查看联机的"添加和删除注册表中的信息"和"编辑注册表数据"的帮助主题或"改变项和值"联机帮助主题在注册表编辑器中。

    注: 您应该备份注册表之前对其进行编辑。
  2. 运行注册表编辑器 (Regedt32.exe)and 找到以下子项:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ < 我服务 >
  3. 从编辑菜单中单击添加项。键入以下,然后单击确定:

    键名称: 参数
    类: < 将保留为空 >
  4. 选择参数密钥。
  5. 从编辑菜单中单击添加值。键入以下,然后单击确定:

    值名称: 应用程序
    数据类型: REG_SZ
    字符串: \

    其中 \ 是驱动器,包括该扩展名的应用程序可执行文件的完整路径 (即,C:\WinNT\Notepad.exe)
  6. 关闭注册表编辑器。
默认状态下,新建的服务它配置为在系统重新启动时自动运行。为此设置更改手动从控制面板运行服务小程序,并启动值更改为手动。设置为手动服务可以启动几种方法之一:
-从在控制面板中的服务小程序

-从 MS-DOS 命令提示符处键入以下内容:

NET START < 我服务 >

-使用 Sc.exe 实用程序从资源工具包。键入从 MS-DOS 命令提示符下以下内容:

\Sc.exe 开始 < 我服务 >

所在的驱动器和目录的 Windows NT 资源工具包 (即,C:\Reskit)。

有关安装和删除用户定义的服务的详细信息,请参阅 Srvany.wri 文档提供与 Windows NT 资源工具包实用程序 (即,C:\Reskit\Srvany.wri)。此外可以在 Common\Config 目录中的 Windows NT 资源工具包光盘上找到此文档。