I am writing a simple batch automation script. I will use runas command to run cmd.exe under another user account. The system asks me to input password. How to response the input request from script. The command is something like this.
runas /noprofile /user:testuser1 cmd.exe
You can use the below line to auto enter the password while using runas, you will have to use a switch /savecred. You'll have to enter the password on the script's first run, but it will be saved after that.
runas /noprofile /user:joe@example.com /savecred script.bat
or
runas /noprofile /user:joe-pc\joe /savecred script.bat
If you want to delete saved password, then you will have to search for Credential Manager in Control Panel.