Wednesday, April 27, 2016

Use “runas” when testing different user roles

A common scenario when testing SharePoint is to switch between multiple user accounts to imitate different user roles. A normal way to do this is to use SharePoints “sign in as a different user” function or right click on a browser/program and use the “run as a different user” function in windows.

The first method can result in you are sign in as the current user when you are browsers other resources dependent on your internet explorer settings.

The second will solve this problem. But you need to enter username and password each time you start a new browser session.

To overcome you need to enter username and password each time. You can use the “runas” program call from a .bat file. With the syntax like this, can you indicate the username. And you only need to enter the password the first time you run the .bat file:

runas /user:[domain\username] /savecred “[path to browser/program]”


runas /user:domain\SP13TestAO1 /savecred "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

And create a .bat file for each user role, it is easy to switch between user session:


1 comment:

  1. Great tip!

    I also use two bookmark(let)s, like this:

    1) Log out:

    2) Log in:
    javascript:document.getElementById("use_another_account_link").click();void(document.getElementById("cred_userid_inputtext").value="");document.getElementById("cred_password_inputtext").click();setTimeout("void(document.getElementById('cred_password_inputtext').value='YourPassword');document.getElementById('cred_sign_in_button').click();", 2000);

    The reason for the 2000 ms delay is that o365 checks if it needs to differentiate between accounts with the same email address - or if you're a corporate user with a custom login screen. And yes, focus() should be sufficient to provoke this check, but it isn't - so click() it is.

    You can have different bookmarklets for different accounts. The big caveat is that your password is stored in the bookmarklet...