Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-24 04:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found