在交互式会话中启动 Windows 服务 [英] Starting a Windows service in an interactive session

查看:13
本文介绍了在交互式会话中启动 Windows 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一位同事有一个批处理脚本程序,它需要以控制台模式在 Windows Server 上运行,以便它可以访问 Windows 交互式会话.服务器会定期自动重启(有一个无关的闭源应用程序运行在我们无法控制的这台机器上).重新启动后,他想自动启动 Windows 交互式会话并运行此脚本,此外该服务还需要访问网络资源(尤其是 CIFS 驱动器).

A colleague has a batch script program which needs to to run on a Windows Server in console mode, so that it has access to a Windows interactive session. The server is rebooted at regular intervals automatically (there's an unrelated closed-source application that runs on this machine that we have no control over). After a reboot he wants to automatically start a Windows interactive session and have this script run, plus the service needs to also have access to network resources (CIFS drives, in particular).

这是我们迄今为止尝试过的:

Here's what we've tried so far:

  1. 作为 Windows 服务启动.这失败了,因为 Windows 服务可以访问交互式会话访问网络资源,但不能同时访问.
  2. 使用 Microsoft 管理控制台添加脚本以在启动时运行,但是这不起作用.
  3. 使用 HKLM 注册表项开始运行此脚本,但是只有当我们在服务器上手动打开远程桌面会话时它才会启动.
  4. 创建计划任务.调用的程序无权访问交互式 Windows 会话.
  1. Start as Windows service. This failed, since a Windows service can either have access to interactive session or to network resources, but never both.
  2. Used Microsoft management console to add the script to run at startup, however this did not work.
  3. Used an HKLM registry key to start to run this script, however it only gets started when we manually open a remote desktop session on the server.
  4. Creating a scheduled task. The program invoked did not have access to interactive windows session.

还有其他建议吗?(或者他在设置这些建议之一时可能遗漏了什么?)

Any other suggestions? (Or maybe he missed something when he set up one of these suggestions?)

推荐答案

如果服务上的Interact with desktop"不够用(我见过少数不合适的情况),可以结合 AutoAdminLogon.在 HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon 下创建三个(或四个域)REG_SZ 值:

In case "Interact with desktop" on the service is not enough (I have seen a handful of cases where it is not), you can combine it with AutoAdminLogon. Create three (or four for a domain) REG_SZ values under HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon:

  • 默认用户名
  • 默认密码
  • 默认域
  • 自动管理员登录

AutoAdminLogon 应该设置为 string "1",其他的不言自明.

AutoAdminLogon should be set to the string "1", the others are self-explanatory.

显然,这存在足以让木星飞过的安全问题.

Obviously this has security issues big enough to fly Jupiter through.

这篇关于在交互式会话中启动 Windows 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆