http://www.opensubscriber.com/message/perl-win32-users@listserv.ActiveState.com/409678.html?
use Win32; use Win32::Process; use Win32::AdminMisc; use Win32::API; logit("Script Started...."); $exeFile = "C:\\windows\\notepad.exe"; $domain = 'YourDomain'; $value1 = 'YourId'; $value2 = 'YourPassword'; if(Win32::AdminMisc::LogonAsUser($domain, $value1, $value2, LOGON32_LO +GON_INTERACTIVE )) { $name = Win32::AdminMisc::GetLogonName(); if ( "\L$value1" ne "\L$name") { logit(" The Login Failed\n domain: $domain user: $value1 +Whos logged in: $name", "-d"); } else { logit(" $domain\\\\$value1 Logged in.."); } } else { logit(" The Login Failed For user: $value1", "-d"); } #Create the process object. if(Win32::AdminMisc::CreateProcessAsUser($exeFile)) { logit(" Started: $exeFile"); } else { logit(" Failed to Start $exeFile ", "-d"); } Win32::AdminMisc::LogoffAsUser(); exit; sub logit { open(log_out,">>script.Log") or die "Can't write to log: $! \n"; $str = (1900+(localtime)[5])."/".sprintf("%02d",(1+(localtime)[4]) +)."/". sprintf("%02d",(localtime)[3])." ".sprintf("%02d",(localtim +e)[2]). ":".sprintf("%02d",(localtime)[1]).":".sprintf("%02d",(loca +ltime)[0])." "; print log_out $str, $_[0], "\n"; close(log_out); }

In reply to Re: Win32::API and CreateProcessWithLogonW by Anonymous Monk
in thread Win32::API and CreateProcessWithLogonW by slloyd

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.