Windows10 App Launch as different user using Appium Code

Can anyone please tell me how to launch an windows10 application as different user from my code. like we do with “Runas” Command?

Currently if I launch using the below command its launching with my user credentials. I want to use different credentials while launching the app. Thanks in advance.

AppiumOptions opt = AppiumOptions();
opt.AddAdditionalCapability(“app”, “C:\Calculator.exe”);
WindowsDriver session = new WindowsDriver(new Uri(“”), opt);

Windows provides runas command for such purpose. In the recent Appium release Windows driver got a possibility to run power shell scripts:

So, you could start the session on Root app, execute the desired app with PowerShell, stop the session and then start a new one by providing appTopLevelWindow
value of your app launched under different user account to it. Also, I suppose the Appium process itself must be running under administration account to make that possible

1 Like