即使在用户注销后,仍在Windows中运行Java进程 [英] Running a Java process in Windows even after the user is logged out

查看:92
本文介绍了即使在用户注销后,仍在Windows中运行Java进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件,可在Windows 2003服务器中启动Java进程.根据安全策略,如果用户在特定时间段内处于非活动状态,则该计算机的用户将被强制注销.问题在于,当用户注销时,该过程也会终止.

I have a batch file that starts a Java process in a Windows 2003 server. As per the security policy, the users of that machine are logged off forcefully, if the user is inactive for a certain period of time. The problem is that when the user is logged out, the process also dies.

我安排了一个新任务(控制面板"->计划任务"),并选择了计算机启动时"选项,并在那里提供了用户帐户详细信息.但这似乎没有任何效果,用户仍然注销并且该进程终止.是否需要重新启动才能使此更改生效?重新启动后,我能否达到预期的效果(使过程保持活动状态)?

I scheduled a new task (Control Panel -> Scheduled Tasks) and selected the option of 'When my computer starts' and gave the user account details there. But it doesn't seem to have any effect, the user is still logged out and the process dies. Is a reboot necessary to make this change effective? And after the reboot, will I achieve what I'm expecting (keeping the process alive)?

或者,作为Windows服务运行此过程是否可以解决问题?如果是这样,您能告诉我如何制作Java程序或批处理文件以作为Windows服务运行吗?我不希望使用任何其他第三方工具或库.

Alternatively, will running this process as a Windows Service solve the problem? If so, can you please let me know how I can make a Java program or a batch file to run as a Windows Service? I would prefer not to use any other third party tools or libraries.

谢谢

推荐答案

用srvany.exe包装该进程并作为服务启动也可以.

Wrapping the process with srvany.exe and launching as a service would work as well.

http://support.microsoft.com/kb/137890

这篇关于即使在用户注销后,仍在Windows中运行Java进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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