Starting a Java process on Windows even after a user logs off

I have a batch file that starts the Java process on a Windows 2003 server. In accordance with the security policy, users of this machine are forcibly deleted if the user is inactive for a certain period of time. The problem is that when the user logs out, the process also dies.

I planned a new task (Control Panel โ†’ Scheduled Tasks) and selected the option โ€œWhen will my computer startโ€ and provided the data for the user account. But it seems that this has no effect, the user will still be logged out and the process will die. Need a reboot to make this change effective? And after rebooting, can I achieve what I expect (by supporting the process)?

Alternatively, will this process be run as a Windows service to solve this problem? If so, can you tell me how I can make a Java program or batch file to work as a Windows service? I would prefer not to use any other third party tools or libraries.

thanks

+5
source share
5 answers

Wrapping a process using srvany.exe and starting as a service will work.

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

+5
source

If you want it to run as part of Scheduled tasks, you need to make sure that you did not perform the โ€œonly at user startupโ€ check, which usually means that you need to provide a password.

The Windows service will be the usual way: the Java service wrapper is a third party, but many people use it.

If you really did not want to use a third-party method, you can use svrany.exe (http://support.microsoft.com/kb/137890) on WIndows NT or later, but it is not designed specifically for Java.

+11

Java Wrapper, java- Windows. , srvany.exe, .

+1

, , jvm,

"java -Xrs"

-Xrs

0

,

Idle Solution will write a Windows VC ++ (.net) creation program to run .bat / .exe as a system service with all the necessary callback methods for SCM.

Note : 1. Wrapping a process using srvany.exe will not work because it does not have a callback process in SCM (Service Control Manager). 2. And the Wrapper Java service is a third-party API (many of them are licensed by LGPL).

0
source

All Articles