Launch Internet Explorer as another AD user

Here is a script I wrote using a DOS batch file for testing Active Directory security of a web application. It will launch an Internet Explorer session as a selected AD user then open a selected page.

This script:

  1. Allows the user to select an Active Directory account from a list
  2. Allows the user to select an environment from a list
  3. Launches an Internet Explorer instance running as the selected user, and opened to the selected portal.

The script will save the password for each user in your registry, meaning you only need type in the password the first time you connect as a user.

It has been tested with Windows 7 and Windows XP.

Click the image to download the script, or copy/paste it from below.
Click to Download

@echo off
echo =-=-=-=-=-=-=-=-=-=-=-=-=-
echo Internet Explorer Launcher
echo =-=-=-=-=-=-=-=-=-=-=-=-=-
echo.
echo Authored by Andrew Mosey
echo 21/02/2012
echo.
echo I hope that the information on these script pages is valuable to you.
echo Your use of the information contained in these pages, however, is at
echo your sole risk. All information on these echo pages is provided "as -is",
echo without any warranty, whether express or implied, of its accuracy,
echo completeness, fitness for a particular purpose, title or non-infringement,
echo and none of the third-party products or information mentioned in the work
echo are authored, recommended, supported or guaranteed by Andrew Mosey.
echo Further, Andrew Mosey shall not be liable for any damages you may sustain
echo by using this information, whether direct, indirect, special, incidental
echo or consequential, even if it has been advised of the possibility of such
echo damages.
echo.
echo.
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo Select the letter corresponding to the login you want
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo.
:: Edit the list of users below as required
echo a cognostest01
echo b cognostest02
echo c cognostest03
echo d cognostest04
echo e cognostest05
echo f cognostest06
echo g cognostest07
echo h cognostest08
echo i cognostest09
echo j cognostest10
echo k cognostest11
echo l cognostest12
echo m cognostest13
echo n cognostest14
echo o cognostest15
echo p cognostest16
echo q cognostest17
echo r cognostest18
echo s cognostest19
echo t cognostest20
echo u cognostest21
echo v cognostest22
echo w cognostest23
echo x cognostest24
echo y cognostest25
echo z cognostest26
echo 0 cognostest27
echo 1 cognostest28
echo 2 cognostest29
echo 3 cognostest30

:: Edit the allowed options on the choice command to match your number of user

selections
choice /c abcdefghijklmnopqrstuvwxyz01234
:: Pad a leading 0 if the user has select 1 to 9
IF %ERRORLEVEL% LEQ 9 (set server=0%ERRORLEVEL%) else (set server=%ERRORLEVEL%)

echo.
echo.
echo.
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo Enter the letter corresponding to the environment you want
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo.
:: Edit the list of environments below as required
echo a Dev
echo b Test
echo c Prod

:: Edit the arguments in the choice command to match your environments
choice /c abc
:: Edit the environments below as required
if ERRORLEVEL 1 set portal=http://dev/cognos
if ERRORLEVEL 2 set portal=http://test/cognos
if ERRORLEVEL 3 set portal=http://prod/cognos

echo Launching Internet Explorer as %DOMAIN%\cognostest%server% to %portal%
echo.
echo Note: if this is the first time you are connecting as a user, you will need to

enter their password.
echo.
runas /user:au\cognostest%server% /savecred "C:\Program Files\Internet Explorer

\iexplore.exe %portal%"
Tags: ,

0 Comments

You can be the first one to leave a comment.

Leave a Comment