I'm writing a Python script (on Windows) which must be run under an elevated CMD (because it runs a subprocess
call which must have administrator privileges).
However - inside the script, there's a part which doesn't work when run as admin, but does work when run as a normal user (accessing a mapped network drive).
I would like to un-elevate the script for a particular part, or just in the middle of it.
Also, since the script wil be run in an automated way, I would like no need for user clicking or input during the script.
For example:
do_stuff_as_user_x_admin()
un_elevate()
do_stuff_as_user_x_non_admin()
How can I achieve this?