Running Apps as Different Users With Run As in Windows 7

Spread the love

Before you start

Objectives: Learn how to run different apps in Windows 7 by different users for testing purposes. We will be using the Run As feature for this.

Prerequisites: no prerequisites.

Key terms: Run As, user account, Windows 7, application, app, right-click, command line


 Run As

When we right click some application, we will see an option to simply open the application, or to run it as administrator.

 1 Right Click

Right-Click Menu

If we choose the “Run as administrator” option, the app will open with administrative rights. One other option that we have is to hold the Shift key while we right click on the app icon. This will bring the “Run as different user” option on the list.

 2 Run as different user

Shift + Right Click Menu

With the “Run as different user” we can open the app with someone we actually specify. This way we can test applications as other users. In order for this feature to work, the service “Secondary Logon” has to be started.

 3 Secondary Logon

Secondary Logon Service Started

The Secondary Logon service is configured to start manually by default. So, we should set it to start automatically if we plan to use “Run as different user” feature.

Let’s see an example. We have a user account named Students which is member of the Users group only.

 4 Students User Account

Students User Account

Now, let’s try to open Computer Management snap-in as that user and try to do some things that only administrators should be able to do. First we will right click Computer Management and choose the “Run as different user” option.

 5 Run Administrative Tools

Running Computer Management

Btw. Computer Management icon can be found in Control Panel > Administrative Tools  (icons view). When we do that, the Windows Security window will appear. Here we have to enter the user name and the password of the user which we want use to open the application (Students in our case).

 6 Windows Security

Windows Security Window

The Computer Management console will appear. Keep in mind that we will be able to do some actions as ordinary user here, but some actions should be denied. For example, if we try to create a new user account in the Local Users and Groups, we will get a warning like this:

 7 Creating User Denied

User Creation Denied

We were denied to create a new user. Remember, this happened because we ran the Computer Management console as a Students user account which is member of the Users group only (it doesn’t have administrative rights).

Also, let’s try to check Device Manager and see what happens.

 8 Device Manager View Only

View Only Device Manager

We got a warning that we can only view device settings (not change them), since we are logged on as a standard user (actually we ran the app as a standard user). So, as we can see, this feature is great if we need to test how our apps will behave when different types of users try to use them.

 Run As in Command Line

We can use the Run As feature in the Command Line. The command is the “runas”. We have to specify the user which we want to use, and we also have to specify the app we want to run. We have to use the full path to the application. In our case we will again use the Students user account and we will try to open the Registry Editor. The full path to Registry Editor app is C:\Windows\system32\regedit.exe. The full command looks like this: runas /user:Students C:\Windows\regedit.exe. When we hit Enter, we will be prompted to enter the password for Students.

 9 Run As Command

runas Command

 We can specify to save the credentials so we don’t have to enter the password every time we run the command. To save the credentials, we simply enter /savecred switch in the command, like this: runas /user:Students /savecred C:\Windows\regedit.exe. We can use the Credential Manager (located in Control Panel) to manage saved credentials.

Keep in mind that runas cannot execute an application that requires elevation if the target user account’s UAC settings include prompt for consent or prompt for credentials.