how to start tomcat service as administrator

4.9k views Asked by At

I had met a problem.I want use "RunTime.exec()" to run cmd in my web app while the tomcat service doesn't start as adminstrator and has no privilege to run cmd. So ,if there has a way to start the service as adminstrator auto but not manual click the tomcat.exe ?

1

There are 1 answers

1
Olaf Kock On

There's one principle that you shall always keep in mind: An application that you can reach from the internet must always be run with as minimal permissions as possible. This totally (always!) rules out to run as an administrator. In case someone finds a security issue in your application, you don't want to provide them with free administrator privileges on top.

Even the permission to execute cmd is questionable to have for an internet-reachable process. In a hardened system this would rather be the task of another server, running with different privileges (again, not administrator) that your webserver (tomcat) would connect to.

As quickfix you might want to provide the CMD execution permissions to the user that your tomcat runs on. As a very-quick-fix you might change the tomcat service configuration - where you configure that tomcat shall run as a service (and where you configure the list of autostarting services) you can also specify the user account that it runs under. I'm not giving exact instructions for the reasons given in the first two paragraphs - I wholeheartedly suggest that you change your approach.