Answer the question
In order to leave comments, you need to log in
How to execute a command in command line with administrator rights in Windows 10?
Hello. You need to write a script that will restart the service. You can only restart the service with administrator rights. What needs to be written in the script so that each command is executed with administrator rights?
I tried runas /user:Admin "net stop ServiceName", but it doesn't help (it doesn't stop the service and asks for a password).
UPD: The person here suggested using a shortcut, and specify in its properties that you need to run it with administrator rights. This partially helped. My script itself is called from a program written in Java, so I cannot interact directly with the commands. So, when I did this, the service began to stop successfully, but at the same time it asked for a username and password. It would be desirable to drive in login and the password at once in a script. It's just that this script should work automatically.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question