Hello,


Not sure if this is a bug or not but we hit this problem when using Win32::AdminMisc::CreateProcessAsUser:
Error: Incorrect function.


Maybe you can shed a light on what's wrong? (or on what we might be doing wrong?)
Please Help (!) Feedback greatly appreciated. Thank you for your time (!)


Version is:
===========
Y:\xavier>perl -MWin32::AdminMisc -Iy:\xavier\perl\lib -le "print $Win32::AdminMisc::VERSION"
20030714


What we see on screen when executing is:
========================================
Enter Password:********
User(uuuuuu) Domain(dddddd) Password(********) Process (cmd)
Sucessfully logged on as uuuuuu .
Launching cmd...
Failed.
Error: Incorrect function.


What I found already
====================
When searching the Internet with
Win32::AdminMisc "Incorrect function"
I find an old 2003 entry describing this same error
http://www.issociate.de/board/post/57431/Win32::AdminMisc::LogonAsUser.html


Script contents here
====================

use Win32; use Win32::AdminMisc; my (undef, $Domain, $User) = ( $ARGV[0] =~ /((.*?)\\)?(.*?)$/ ); my $Password = $ARGV[1]; if( '*' eq $Password){ print "Enter Password:"; $Password = <STDIN>; chop $Password; } my $Process = $ARGV[2]; ("" eq $Domain) ? $User: "$Domain\\$User"; print "User($User) Domain($Domain) Password($Password) Process($Proces +s)\n"; #exit 0; if(Win32::AdminMisc::LogonAsUser($Domain,$User,$Password,LOGON32_LOGON +_INTERACTIVE)){ my $LogonUser = Win32::AdminMisc::GetLogonName(); print "Sucessfully logged on as $LogonUser .\n"; print "\nLaunching $Process...\n"; my $Pid = Win32::AdminMisc::CreateProcessAsUser( $Process, "Flags", CREATE_NEW_CONSOLE, "XSize", 640, "YSize", 400, "X", 200, "Y", 175, "XBuffer", 80, "YBuffer", 175, "Title", "Title: $User" . "'s $Proc +ess program", "Fill", BACKGROUND_BLUE | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN, ); if($Pid){ print "Successfull! The new process PID is $Pid.\n"; } else{ print "Failed.\n\tError: ", Error(), "\n"; } } else{ my $err=Win32::FormatMessage( Win32::AdminMisc::GetError()); print "HERE $err\n"; } sub Error{ return Win32::FormatMessage( Win32::AdminMisc::GetError()); } exit 0;

In reply to Error: Incorrect function when using Win32::AdminMisc::CreateProcessAsUser by merlinX

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.