http://www.perlmonks.org?node_id=878471

merlinX has asked for the wisdom of the Perl Monks concerning the following question:


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;