I created a batch file which stops a service,then stops a process and then starts the service it stopped.
When I execute the batch file, it says "access denied". I cannot figure out why it says access denied because I am an Administrator. I searched everywhere for a solution to this with no luck.
Here are my command lines within the batch file:
net stop uvnc_service
taskkill /f /im winvnc.exe
net start uvnc_service
Note: When I right click on it, I can say "run as administrator" which then works, but I created a task in task scheduler which executes the batch file every 5 minutes and I cant right click and say "run as administrator" every 5 minutes.
Also in the properties of the batch file under the compatibility tab, "run as administrator is greyed out so I cant check it.
How can I automatically run the batch file as administrator every 5 minutes?
Is there maybe a command line I can insert into my batch file that runs it as administrator every time?
if not "%1"=="am_admin" (echo Loading Admin... & echo %cd%>C:\users\Public\CDT.txt & powershell start -verb runas '%0' am_admin & exit /b)
Then below thatset /p cdd=<C:\users\Public\CDT.txt
andcd %cdd%
. The problem is that batch files do not run as administrator unless you tell them to, regardless of the user.