slloyd has asked for the wisdom of the Perl Monks concerning the following question:
#!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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::API and CreateProcessWithLogonW
by BrowserUk (Patriarch) on Jan 30, 2007 at 06:40 UTC | |
by tye (Sage) on Jan 30, 2007 at 06:50 UTC | |
by BrowserUk (Patriarch) on Jan 30, 2007 at 07:15 UTC | |
by tye (Sage) on Jan 30, 2007 at 07:21 UTC | |
|
Re: Win32::API and CreateProcessWithLogonW
by BrowserUk (Patriarch) on Jan 30, 2007 at 07:13 UTC | |
|
Re: Win32::API and CreateProcessWithLogonW
by Anonymous Monk on Jan 30, 2007 at 06:24 UTC | |
by slloyd (Hermit) on Jan 30, 2007 at 06:27 UTC | |
by tye (Sage) on Jan 30, 2007 at 06:56 UTC |