lo monks I am using perl on windows 2000 for a lot of admin work. I am trying to automate the runas command to get a dos prompt with admin rights and use that to move some files etc. runas /user:administrator cmd in windows with will give you Enter password for administrator: Is there a way to get perl to send the password to the prompt and then ENTER this would leave me with a admin cmd which I would need to send further instructions to. I can do this in vbs but I want to make it an exe so the admin password is not clear text. I tried
system('runas /user:administrator cmd'); sleep2; system('thepassword'); sleep2; system('echo did it work?'); but naturally the system waits until runas has finished before going o +n. VBS handles it like this set WshShell = CreateObject("WScript.Shell") WshShell.Run "C:\Winnt\System32\Runas.exe /USER:administrator cmd" WScript.Sleep 2000 '1 Send keys to enter password. WshShell.SendKeys "thepassword" WScript.Sleep 580 '1 Send Enter key. WshShell.SendKeys "{Enter}" WScript.Sleep 500 '1 Send other keys. WshShell.SendKeys "echo commands here run in admin mode" WScript.Sleep 500
any ideas?

Edit by tye to replace password


In reply to sending test to command prompt by ironpaw

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.