Dear Monks,

I am attempting to execute a windows program that expects input from the user once started. I have tried using system and pass the value as one of the arguments, but this did not work because the program will not accept this data as a parameter.

The program in question is "runas". It is run like this:

runas /user:username "command to execute"

Once that command is started, it prompts for a password. The design of the tool does not allow the password to be passed as a parameter. (I am on Windows 2000)

I have tried this without success:

system('runas /user:username "net localgroup administrators %username% +@%userdnsdomain% /ADD"', 'password');

The response I get is:
*Enter password for oitcontractor\administrator:RUNAS ERROR: Unable to accept input
*'administrator' is not recognized as an internal or external command, operable program or batch file.

So then I thought I should try putting the password in backticks on the next line, and that doesn't work either. I know this is a long post for what should be a short question, but I wanted to show you that I have tried to solve this before asking you.

I did a supersearch for "windows program input" and found this, which mentions Win32::Console but I have not been able to figure out how to use it. Can anyone confirm that Win32::Console can accomplish this and point me to some decent examples. I read the perldoc on it and I am a bit confused. If it cannot then are there any other solutions?

Thanks, disciple


In reply to Pass expected input to Windows program by disciple

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.