简体   繁体   中英

Batch file running Java program on User Login/ Logoff

I have a Java application packaged up as a jar that I want to run when the user logs in and logs out on Windows.

I have added the command to do this in a batch file and added it to the group policy login/ logoff with some logging so I can debug it.

When I run the batch file logged in as an admin user it executes correctly, however when I log out/ in, it skips over the java command in the batch file.

I'm guessing this is probably due to permissions issues with the local system running a java application, is there anyway I can get around this/ an alternative?

You can try to use a scheduled task triggered to launch at startup. You can use a specific user, and you probably will receive a better log if the process fails.

It was 'skipping' over the Java Execution because there was a path formatting issue and I forgot to add the standard error output to the logging ('2>&1' at the end of the stream) I didn't notice the error.

Specifically in my java.policy file the path used '\\' instead of '/'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM