4

I have a c++ service application that launches a Powershell script (powershell.exe script.ps1). In the script an executable is run but needs to be run with different user credentials. Is there a way to do this in Powershell with the invoke-expression cmdlet or some other way?

1 Answer 1

6

Try Start-Process e.g.:

Start-Process cmd.exe -arg "/k whoami.exe" -Credential (Get-Credential)

Of course, for your script you will need to create a credential programmatically rather then using the Get-Credential which prompts for username/password.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.