Search code examples
javauacprocessbuilder

Elevate process with UAC java


I need to install a windows service from inside my Java application. I have a bat file, that does that. Thing is, it needs elevation.

How can I easily do that from my Java code?

I've looked here: Elevating a ProcessBuilder process via UAC? and it seems like a freakishly large code for such a simple operation. Is there an easier way? That thread is 3 y.o., so maybe something happend since then?


Solution

  • If you start your application with elevated permissions it should do the trick from what I remember.

    The alternative is that you wrap the bat file in say an exe that has a manifest file that requires elevated permissions. This will prompt the UAC.

    See this SO post about creating bat files with elevated permissions. Elevating batch permissions