How do I run a program as a different user?

Question

How can I create a scenario to run a program as a different user?

Solutions

There are a couple of ways to create a scenario to run a program as a different user.

Solution #1:

Windows allows you to start a program as an administrator (or a different user) by right-clicking on the application icon, and selecting the option "Run As USER".

You can create a scenario in ScenarioBuilder to imitate these actions by doing the following:

  1. Add a Find Image action to look for the application icon.
  2. Add a Move Mouse and Click action as a child of the previous action. Select "Right" for Button and "Click" for Click Type in the properties.
  3. Add a Find Image action to look for the option "Run As USER".

Note: To capture the image, you will need to press the Ctrl key to change the image capture mode. Next, right click on the application icon to reveal the image you need to capture. Then press Ctrl key again to change the image capture mode and select the correct image.

     4. Add a Move Mouse and Click action as a child of the previous action.

How to run a program as a different User_ (360005107894)_Screenshot_6

Solution #2:

You can also start a command prompt in ScenarioBuilder and use the RunAs command in windows to start your application with a specified user. To do that follow the steps below. We will use running Notepad as ruser001 in the example.

  1. Add an Open with File Association action to open the command prompt (C:\Windows\System32\cmd.exe).
  2. Add a Type Text action.
  3. In the Text property, enter the command to open the application with the user you want to use to open the app (runas /noprofile /user:ruser001 notepad.exe).
  4. In the Additional Keys and Actions property > First Key click the ellipse button and then press Enter.
  5. In the Additional Keys and Actions property > First Action open the drop-down and select Press.
  6. Add another Type Text action.
  7. In the Text property, enter the password for the user you entered in step 3.
  8. Select the Encrypt Text property to encrypt the password.
  9. In the Additional Keys and Actions property > First Key click the ellipse button and then press Enter.
  10. In the Additional Keys and Actions property > First Action open the drop-down and select Press.
How to run a program as a different User_ (360005107894)_inline-1676466454