Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Error: Incorrect function when using Win32::AdminMisc::CreateProcessAsUser

by merlinX (Novice)
on Dec 22, 2010 at 10:37 UTC ( #878471=perlquestion: print w/ replies, xml ) Need Help??
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;

Comment on Error: Incorrect function when using Win32::AdminMisc::CreateProcessAsUser
Download Code
Re: Error: Incorrect function when using Win32::AdminMisc::CreateProcessAsUser
by jfroebe (Vicar) on Dec 22, 2010 at 15:19 UTC

    What version of Windows are you running this code on?

    Jason L. Froebe

    Blog, Tech Blog

      I tested this on a windows XP Win32::GetOSVersion() dump shows
      $VAR1 = [ 'Service Pack 3', 5, 1, 2600, 2, 3, 0, 256, 1 ];
      I tested this also on a windows 2003 Win32::GetOSVersion() dump shows
      $VAR1 = [ 'Service Pack 2', 5, 2, 3790, 2, 2, 0, 272, 3 ];

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://878471]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2014-12-18 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls