Running windows program as different users:
Sometimes, when developing programs, there arises a need to execute computer programs as different users. During my own development process, I encountered this requirement and sought a solution. Fortunately, I discovered a method to address it. The desired functionality for my program was to automatically log into user accounts, perform specific tasks, and then move on to the next user. However, a challenge arose when running the command within the code, as it prompted for a password each time. To automate this process, I incorporated the "SaveCred" command in my code. This command allowed me to store and retrieve the required credentials, enabling the program to execute seamlessly. By employing the "SaveCred" command, I successfully achieved the desired automation, allowing the program to efficiently execute tasks across multiple user accounts without the need for manual intervention or repeated password entries.
My Solution:
This is Python Code
os.system(f'cmd /c "runas /user:{a} /savecred "C:\Program Files\\application\App\appy""')
the give {a} is a looping variable which used as username as well as password. in my case you can set your cod according to your usage.
if you need any help feel free to contact us.
Thankyou.
Post a Comment