Reputation: 1457
I have a .cmd file that I need to invoke from a powershell file. But constraint is that I need to execute .cmd file as a different user as well as process should not prompt for authentication. I can provide password with command itself, it is not an issue.
Can someone please help me this.
Upvotes: 1
Views: 2049
Reputation: 14039
Use runas
runas /savecred /profile /user:<username> <command>
It will prompt password first time and save the credential. So from 2nd time onwards, it won't ask for a password.
For eg. if you want to run test.cmd as user varun, then
runas /savecred /profile /user:varun test.cmd
Upvotes: 2