I have a script that works in 2 parts. The first part requires administrator access (updates the HOSTS file and performs some copy / overwrite operations). After this part ends, I need to map the drive using the node alias to the first part of the updated script.
I figured out how to get elevated privileges using this SO question . But disk mapping (while at the administrator) displays the disk in an administrator session. I need to βreleaseβ back to user mode in order to run the second script.
This script I run at least once a day and possibly several times a day. I am trying to create a solution that is only 1.bat file if possible. For reasons, the scripts are written in perl.
What I tried:
- Using runas / user: regular_user command (this does not work)
- 1 bat file Using CALL for two batch files (this "works", but for some reason both run simultaneously)
- Run two bat files individually and manually.
- Search SO, but I could not find the administrator-> user, but only user-> admin
TL; DR: How to disable user mode from administrator mode in a batch file?
source share