I have a requirement to be able to run a command from the start menu as an arbitrary user, given the username and password. Any idea how I can accomplish this in Win32?

Win32::Process does not allow this (I've looked), and it appears I could just use the "RunAs" command, but the problem with that is you can't specify the password on the command line -- I intend to gather the password from a Tk dialog. So, if I did use RunAs, I'd need to drive it with something like Expect (but for Win32). Any ideas how to do this cleanly?

Any good module recommendations? I'd rather not shell out to runas if I can help it, since I'm not sure runas ships with all Windows versions, and I'm not sure how to feed the password to the RunAs.exe binary once it is running.

Thanks folks -- I appreciate your help!


In reply to Running Win32 binary as arbitrary user -- in Perl by flyingmoose

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.