in reply to Windows runas command

Untested (I'm away from my PC), but provides the general idea:
my $User="Somebody"; my $Pass="ThisIsInsecure!"; my $Program_to_run="notepad.exe"; my $result=`echo $Pass|RunAs /User:$User $Program_to_run`;
If the command prompt is not invoked correctly, you may need to add a "cmd/c " before the "echo".

     Theory is when you know something, but it doesn't work.
    Practice is when something works, but you don't know why it works.
    Programmers combine Theory and Practice: Nothing works and they don't know why.         -Anonymous

Replies are listed 'Best First'.
Re^2: Windows runas command
by Anonymous Monk on Feb 14, 2010 at 18:01 UTC
    That is insecure as the password would show in processexplorer(taskmanager)

    What you want is to follow VBS shell code, use Win32::GuiTest or Win32::OLE

      Hi, Thanks for the reply. I am afraid I have to grovel a bit as I am new to Perl and would not have much of an idea of how to best use the modules you mention. Is is possible you could supply an exmple of how they could be used to invoke the runas command.That would be really appreciated,
Re^2: Windows runas command
by flintstone (Initiate) on Feb 15, 2010 at 17:52 UTC
    Hi, Thanks for the suggestion. Gave it a try but basically its the same as things I have tried to do with echo and redirection.It seesms its not possible do do this with Runas. As I mentioned I had considered the React or Expect modules to respond to the password prompt but could not find workable modules for Windows.