Hi All,

I've been using perl for test scripts for several years but have never run into a problem like this before. I'm hoping one of you monks can tell me if it's even possible before I spent a whole lot of time on it.

I'm trying to test a product by using the windows command "runas" to start the product in different user contexts. It's like a windows su. However the folks at MS have decided to make my life difficult. You can start a program as so...

c:\runas /user:winuser "program args"

and it will run program as if you are logged in as winuser. What they've done to make it difficult is that blank passwords may not be used with runas, and the program will not accept a password argument. Instead, as soon as you run this, you get a password prompt...

Enter the password for winuser:

So I'm kind of stumped by this. I've always just used system() and passed it an array containing the name of a program and a list of args. That's fine for the initial invocation of runas, but since it's a missile, there isn't any way to pass something else after the fact.

Interestingly MS did this deliberately to prevent people from doing just what I'm trying to do, except that I'm just trying to do it to test something...

It's a long shot but I was wondering if any of you smart folks could think of a way that a perl script could start runas and then provide a password after the prompt?

There is a windows function called CreateProcessWithLogonW() which looks like it could serve as the basis for a free standing executable that I could call from the scripts which in turn would spawn the application under test in different user contexts. I fear that might be a bit over my head though.

In reply to interactive command session possible? by lisa_lionheart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.