AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Prozesse Starten auf remote Server
Thema durchsuchen
Ansicht
Themen-Optionen

Prozesse Starten auf remote Server

Ein Thema von Centrii · begonnen am 24. Jul 2007 · letzter Beitrag vom 24. Jul 2007
 
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#2

Re: Prozesse Starten auf remote Server

  Alt 24. Jul 2007, 21:09
Your remote process runs in a restricted security context, it does not run in the context of an interactive logon account
(if any), it runs in the security context of the remote WMI service and by default it's impersonating the initiator (the WMI client). What does it mean to the application that was started? First, this application has no way to interact with the user, even when it's a console application, the output will go to a non visible desktop and there is no way to read
from the keyboard.

If you want to start a process remotely I'd suggest remotely installing a service, make that start your process and remove the service upon termination. You can use GetActiveConsoleSession (XP and higher) to obtain the interactive sessionid and then use WtsQueryUserToken to obtain the users token. Lastly use CreateProcessAsUser with the token from WtsQueryUserToken. You can put this in the ServiceStartEvent. Something like this:

Delphi-Quellcode:
procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
var hToken: THandle;
  si: _STARTUPINFOA;
  pi: _PROCESS_INFORMATION;
begin
  ZeroMemory(@si, SizeOf(si));
  si.cb := SizeOf(si);
  si.lpDesktop := nil;

  if WTSQueryUserToken(WTSGetActiveConsoleSessionId, hToken) then
  begin
    if CreateProcessAsUser(hToken, nil, 'cmd.exe', nil, nil, False,
      CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP, nil,
      nil, si, pi) then
    begin
      // Do some stuff
    end;
  end;
  Self.DoStop;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz