Open Multiple SSMS from CMD using Run AS AND prompting for password once

  • Greetz!

    I've got a requirement to open multiple (4) instances of Management Studio in a batch file. Expensive I know but that's what they want. It has to be SSMS and it is an account that is logging in as a Windows Account as opposed to a username/password.

    I've got a script that will loop but I'm passing the username and password. This one does not prompt for the password but fails to login because, I believe, the server only permits Windows Authentication:

    Set _num = 0

    Set /p pwd = "%=%"

    :start

    if %_num% == 3 goto end

    'C:\Program files...sqlwb.exe" -S ServerName -U USername -P pwd

    set /a _num += 1

    go to start

    :end

    pause>nul

    In the same loop i have also tried:

    run as /user: domain\username "C:\Program files...sqlwb.exe"

    but I am prompted for the password each time. If I add the -P parameter it fails with a scolding to enter the pwd only when prompted.

    Is there a way to run a batch file, enter a password once for the RUNAS windows account and use that password in a loop with no more prompts?

    Thanks in advance!

    Even as a mother protects with her life
    Her child, her only child,
    So with a boundless heart
    Should one cherish all living beings;

  • So, if folks are wondering or trying to do the same thing, the RUNAS command does not provide a means to send a password with the command. it was deliberately left out of the command since it presents a security issue.

    Even as a mother protects with her life
    Her child, her only child,
    So with a boundless heart
    Should one cherish all living beings;

  • ok several dumb questions here:

    why do you need to do work via SSMS as different users? why not have a superuser do all the work?

    why cna you not simply use EXECUTE AS ? in a single script?

    why the extra trouble for logging in?

    EXECUTE AS USER='mydomain\SomeGuy'

    ..do work

    REVERT; --change back to sysadmin

    EXECUTE AS USER='mydomain\AnotherGuy'

    ..do work

    REVERT; --change back to sysadmin

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply