Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. function CreateProcessWithLogonW(
  2. lpUsername,
  3. lpDomain,
  4. lpPassword:PWideChar;
  5. dwLogonFlags:dword;
  6. lpApplicationName: PWideChar;
  7. lpCommandLine: PWideChar;
  8. dwCreationFlags: DWORD;
  9. lpEnvironment: Pointer;
  10. lpCurrentDirectory: PWideChar;
  11. const lpStartupInfo: tSTARTUPINFO;
  12. var lpProcessInformation: TProcessInformation
  13. ): BOOL; stdcall; external 'advapi32.dll';
  14.  
  15. procedure TFcatPer.ImhuellaDblClick(Sender: TObject);
  16. var
  17. f:textfile;
  18. l:string;
  19. hToken: THandle;
  20. pi: TProcessInformation;
  21. si: TStartupInfo;
  22. begin
  23. if fileexists(Flogin.ExeHuella) then
  24. begin
  25. try
  26. visible:=false;
  27. // ExecNewProcess(Flogin.ExeHuella,true);
  28. // Runas('Administrador', 'samba', Flogin.ExeHuella+' a');
  29. // RunAsAdmin(self.Handle,Flogin.ExeHuella,'a');
  30. // RunAsAdmin(self.Handle,Flogin.ExeHuella,'a User Name=Administrador;Password=samba');
  31. ZeroMemory(@pi, SizeOf(pi));
  32. ZeroMemory(@si, SizeOf(si));
  33. si.cb:=SizeOf(TStartupInfo);
  34. if LogonUser('Administrador', 'GPOLN', 'samba' , LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, hToken) then
  35. begin
  36. visible:=false;
  37. if not (CreateProcessWithLogonW('Administrador','GPOLN','samba',0,nil,
  38. 'C:\Archivos de programa\GPOLN\Huellas\GPOLN.AFIS.exe a',0,
  39. nil,nil,si, pi)) then
  40. ShowMessage('Error')
  41. else
  42. WaitForSingleObject(pi.hProcess, INFINITE);
  43. visible:=true;
  44. end;
  45.  
  46. i am tested Logon User and CreteProcessWithLogonW with user: Administrador/samba and osbaldojacobo/osbaldo
  47.  
  48. with Administrator/samba, wont work,not run the program with user: osbaldojacobo/osbaldo too wont work, but run the program but without Administrator privileges;
  49.  
  50. thx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement