0
2
How can I run a batch file using an elevated account without the UAC dialog popping up, If I know the password for the account I am trying to use? I am looking for a pure batch/powershell answer, if at all possible.
0
2
How can I run a batch file using an elevated account without the UAC dialog popping up, If I know the password for the account I am trying to use? I am looking for a pure batch/powershell answer, if at all possible.
1
You can't run it as an elevated user without the UAC prompts unless it's turned off.
However, there is another method; use:
psexec -u username -p password
This way, it will execute the batch file with elevation .
1
You normally wouldn't want to do this, in general in breaches security and the point behind elevating the execution, and bypassing the Admin request.
But from my understand you are able to run a batch file with administrative rights, but this cannot be done with the batch file itself.
I may be mistaken, but I believe the question has already been asked and resolved here.
As mentioned in the above link you could preform the following:
Right click batch file > Send to > Desktop (create shortcut)
Another user had also mentioned a new solution here
https://superuser.com/a/852877/676838
REM --add the following to the top of your bat file--
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >>
"%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
This is what I am currently using for requesting UAC, however, as I said in my post, I am looking for a way to get elevation *WITHOUT UAC* and I already know the password. – cascading-style – 2016-12-19T19:26:20.120
1
You may be able to do so, if you create a shortcut based on the program either exe. or batch that you want to execute. You will basically need to create a shortcut that allows administrative rights to be applied. This may be what you are looking for. http://bit.ly/2i2anoj
– Anthony D. – 2016-12-19T19:34:17.533
1Have you tried using RunAs yet? What have you tried already? – Ƭᴇcʜιᴇ007 – 2016-12-19T19:20:28.087
@Ƭᴇcʜιᴇ007
RunAs
only executes it as the account, but will not give out elevation. – cascading-style – 2016-12-19T19:21:48.803If you are asking if you can elevate without the UAC prompt, the answer is no, and this is by design. – Bill_Stewart – 2016-12-27T21:47:41.797
You might check here and play to see if such a solution resolves your issue: http://serverfault.com/questions/734320/allow-standard-user-to-run-program-as-local-admin-without-elevation-prompt/734360#734360
– Pimp Juice IT – 2016-12-28T02:52:52.487