#! perl -slw use strict; use Win32::API::Prototype; sub A2W{ pack 'S*', unpack 'C*', $_[0] } sub W2A{ pack 'C*', unpack 'S*', $_[0] } ApiLink( 'advapi32.dll', q[ BOOL CreateProcessWithLogonW( LPCWSTR lpUsername, LPCWSTR lpDomain, LPCWSTR lpPassword, DWORD dwLogonFlags, LPCWSTR lpApplicationName, LPTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInfo ) ] ) or die $^E; my $si = pack( 'LLLLLLLLLLLL SS LLLL', 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1|0x100, 1, 0, 0, -1, -1, -1 ); CreateProcessWithLogonW( A2W( 'theUsername' ), A2W( '\\.\ ' ), A2W( 'thePasword' ), 0, A2W( 'C:/windows/system32/notepad.exe' ), 0, 0, 0, 0, $si, chr(0) x 100 ) or die $^E;