How do I start/call a batch file from another, but with administrative privileges, so that it doesn't give me errors like the following?
Access is denied error code 5
Here is something like what I would like it to be.
echo PLEASE TYPE YOUR USERNAME AND PASSWORD IN THE FIELDS BELOW.
echo.
echo.
echo.
echo.
set /p u=Username:
echo.
set /p p=Password:
start next.bat %u% %p%
Press and hold down the SHIFT key while you right-click the executable file or the icon for the application, and then select Run as. Select The following user. In the User name and Password boxes, type the administrator account and password, and then select OK.
Click on Command Prompt to open the application and type your first command. Right-click on the application and select "Run as administrator," then a new Command Prompt window opens.
In the Start in (optional) field, enter the directory path to the task files. Click OK. You are prompted for the Windows user name and password. Enter the Administrator user name and password and click OK to run the task.
No matter which way you chose, You must accept run it with admin privilege, so the point is which way is shorter? You could Right Click > Run as administrator
as jean-Michael said although I prefer james approach (using vbScript) but if you don't want to use another vbScript file and just want benefit of just click on batch file and accept run with admin privilege (Note you have one right click and left click less) I suggest you this:
create a shortcut from your batch file and right click on shortcut > Properties > Shortcut Tab > Advanced now check the Run as administrator check-box. every time you execute it from the shortcut you just have one click to accept run it with admin privilege.
Hope this help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With