I need to run a file as another user without it prompting for a password, from my script. How is this done?
Pass Password to runas from Python [duplicate]
There's an executable program called SANUR.EXE that's made for just this kind of situation: you can use it to pipe in the password on the command-line, like this: runas /user:domain\username cmd.exe | sanur mysekritpassword
.
the link is dead, and there are better alternatives than using that program. psexec is one, and sending chars to the input is another (see linked question) –
Endways
Have the user add whatever it is as a scheduled task with a specific name but no schedule, so it can only be invoked manually. They will need to enter the account credentials when creating the task, but only once. Then you can simply tell schtasks
(Windows command line tool) to run it.
© 2022 - 2024 — McMap. All rights reserved.
popen
, provided you have the proper permissions... – Rapid