Just to check if the above reply could be of help, if yes, you may mark useful reply as answer, if not, welcome to feedback.
Best regards,
Sylvia
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
Could you please help me to execute a bat file silently as an administrator. Is it possible to add run as administrator option in a bat file. I tried the below command, but its not worked for me.
msiexec.exe /i "F:\Test\DesktopCentral_Agent.msi" /quiet /norestart
I am getting this error below.
The installer has insufficient privileges to access this directory: C:\Program Files (x86)\DesktopCentral_Agent. The installation cannot continue. Log on as administrator or contact your system administrator.
Just to check if the above reply could be of help, if yes, you may mark useful reply as answer, if not, welcome to feedback.
Best regards,
Sylvia
Try this bat file. If the user right clicks the bat file and selects "Run as Administrator", it will detect that it is elevated and will call the installer. If it is not elevated it will use powershell to invoke the UAC prompt and run the installer.
@echo off
whoami /all | findstr S-1-16-12288 > nul
if %errorlevel%==1 goto NotAdmin
@echo This command prompt is already elevated. Performing install.
msiexec.exe /i "F:\Test\DesktopCentral_Agent.msi" /quiet /norestart
goto end
:NotAdmin
@echo This command prompt is not elevated. Using Powershell to invoke UAC prompt.
Powershell.exe Start-process msiexec.exe -verb runas -argumentlist "/i F:\Test\DesktopCentral_Agent.msi /quiet /norestart"
:end
Hi,
Refer to the link below:
https://social.technet.microsoft.com/Forums/en-US/53ff7268-a82c-4fdb-92b1-6e5b5c206826/installation-failed-in-windows-server-2016?forum=ws2016
Note: This is a third-party link and we do not have any guarantees on this website. And Microsoft does not make any guarantees about the content.
Best regards,
Sylvia
Hi
User has admin rights and able to execute the command. But its need to run as admin to execute the command properly, otherwise it wont work and shows the error mentioned below
"The installer has insufficient privileges to access this directory: C:\Program Files (x86)\DesktopCentral_Agent. The installation cannot continue. Log on as administrator or contact your system administrator."
Based on the question, I am assuming that the user who is running the bat file is a standard user and not an administrator and does not know the administrator password. Is that a correct assumption?
If so, is this what you are looking for?
standard-users-run-program-admin-rights
There is no magic switch to allow a standard user to gain administrator access without somehow providing administrator credentials. That would be a security hole. Of course if you save the credentials of the administrator account as that page describes, that may also be a security hole.
There may be other alternatives (task scheduler) that you could use, but you would need to explain more about what you are trying to accomplish.