aspose file tools*
The moose likes Java in General and the fly likes start windows service from windows 7 from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "start windows service from windows 7 from java " Watch "start windows service from windows 7 from java " New topic
Author

start windows service from windows 7 from java

shihab K Bava
Greenhorn

Joined: Oct 03, 2004
Posts: 12
I am in the middle of a problem. I am trying to start a windows service from java. My OS is windows 7. And I am logged in the machine a my user name (not administrator). I have administrator privilege. I can start the service from the service list. From my java code I am trying to start the same windows service. But from windows 7 I am unable start the service from my java code. Access denied error is returning. When I start the my java application as administrator (right clicking the application icon and start as administrator) I can start the same service. Can somebody help me regarding this?

My source code given below.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

When you're calling your code like that, it's not being executed as Administrator but as yourself. Even though you may have administrative rights, User Access Control (UAC) probably still won't let you do it without confirmation. The problem is, that confirmation dialog is suppressed when you try to execute the command through Java. Try using the runas command:
You will probably be prompted for the password though; I don't really know how to prevent that (or even what the password is, as I've never set one; the user is even disabled on my machine).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: start windows service from windows 7 from java