I am trying to use CreateProcessWithLogonW with Win32::API and cannot seem to get it to work. It always returns "The parameter is incorrect". Any ideas what I am doing wrong?
#!perl use strict; use Win32::API; my $user="username"; my $pass="password"; print createProcessWithLogon('notepad.exe',$user,$pass); exit; ############### sub createProcessWithLogon{ my $program=shift; my $username=shift; my $password=shift; my $LOGON_NETCREDENTIALS_ONLY = 0x2; my $CREATE_NEW_CONSOLE = 0x10; my $CreateProcessWithLogon = new Win32::API('advapi32.dll', 'Creat +eProcessWithLogonW', ['P','P','P','P','P','P','P','P','P','P','P'],'N +') || return $^E; print "calling[$program,$username,$password]\n"; #Set Flag my $dwFlags = 1; # STARTF_USESHOWWINDOW $dwFlags |= 0x100; # STARTF_USESTDHANDLES otherwise we inherit t +he parents handles on 98 # SW_HIDE=0 SW_SHOWNORMAL=1 SW_SHOWMINIMIZED=2 my $show=1; my $si = pack("LLLLLLLLLLLL SS LLLL",68,0,0,0,0,0,0,0,0,0,0,$dwFla +gs,$show,0,0,-1,-1,-1); my $processinfo = pack("LLLL",0,0,0,0); my $num=$CreateProcessWithLogon->Call( $username, #lpUsername undef, #lpDomain $password, #lpPassword $LOGON_NETCREDENTIALS_ONLY, #dwLogonFlags, "hello", #lpApplicationName $program, #lpCommandLine $CREATE_NEW_CONSOLE, #dwLogonFlags, undef, #lpEnvironment ".", #lpCurrentDirectory $si, #lpStartupInfo $processinfo #lpProcessInfo ) || return "Bad Call - $^E"; return $num; }

-------------------------------
Need a good Perl friendly Host Provider?
http://www.dreamhost.com


In reply to 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.