AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Start or end an application on a remote computer.
Thema durchsuchen
Ansicht
Themen-Optionen

Start or end an application on a remote computer.

Ein Thema von haidomingo · begonnen am 25. Nov 2009 · letzter Beitrag vom 26. Nov 2009
Antwort Antwort
haidomingo

Registriert seit: 22. Jul 2009
23 Beiträge
 
#1

Start or end an application on a remote computer.

  Alt 25. Nov 2009, 15:29
Hi
how you can start or end an application on a remote computer (lan)?
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: Start or end an application on a remote computer.

  Alt 25. Nov 2009, 17:58
Google for "Remote Execute Windows" and you find Apps from MS which can do such thinks.
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#3

Re: Start or end an application on a remote computer.

  Alt 25. Nov 2009, 21:30
Another solution is using WMI.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
haidomingo

Registriert seit: 22. Jul 2009
23 Beiträge
 
#4

Re: Start or end an application on a remote computer.

  Alt 26. Nov 2009, 10:17
Zitat von Luckie:
Another solution is using WMI.
Thanks,

I found this:

Delphi-Quellcode:
uses WbemScripting_TLB;

function remoteExecute(programName:string; machine:string=''; user:string=''; password:string=''):string;
var
  SWbemLocator1:TSWbemLocator;
  Service: ISWbemServices;
  InParam, OutParam, SObject: ISWbemObject;
  Method: ISWbemMethod;
  SProp1, SProp2, MyProperty: ISWbemProperty;
  s,methodName:string;
  PropValue:OleVariant;
begin
  methodName:='Create';
// CoInitialize(nil);
  SWbemLocator1:=TSWbemLocator.Create(nil);
  if machine='then
    machine:='.';
  Service:=SWbemLocator1.ConnectServer(machine,'root\CIMV2', user, password, '','', 0, nil);
  Service.Security_.Set_ImpersonationLevel(wbemImpersonationLevelImpersonate);
  SObject:= Service.Get('Win32_Process', 0, nil);

  Method:= SOBject.Methods_.Item(methodName, 0);
  InParam:= Method.InParameters.SpawnInstance_(0);

  MyProperty:= InParam.Properties_.Add('CommandLine', wbemCimtypeString, False, 0);
  PropValue:= programName;
  MyProperty.Set_Value(PropValue);

  MyProperty:= InParam.Properties_.Add('CurrentDirectory', wbemCimtypeString, False, 0);
  PropValue:= Null;
  MyProperty.Set_Value(PropValue);

  MyProperty:= InParam.Properties_.Add('ProcessStartupInformation', wbemCimtypeObject, False, 0);
  PropValue:= Null;
  MyProperty.Set_Value(PropValue);

  OutParam:= SObject.ExecMethod_(methodName, InParam, 0, nil);
// OutParam:= SObject.ExecMethod_(methodName, nil, 0, nil);
  SProp1:= outParam.Properties_.Item('ReturnValue', 0);
  SProp2:= outParam.Properties_.Item('ProcessId', 0);
  case SProp1.Get_Value of
    0:s:='Successful completion.';
    2:s:='Access denied.';
    3:s:='Insufficient privilege.';
    8:s:='Unknown failure.';
    9:s:='Path not found.';
   21:s:='Invalid parameter.';
   else s:='Unknown reply code!';
  end;
  SWbemLocator1.Free;
  service:=nil;
  SObject:=nil;
  OutParam:=nil;
  SProp1:=nil;
  result:=s+'(PID='+inttostr(SProp2.Get_Value)+')';
// CoUninitialize;
end;
Run the application well, but the application not shown on the video to your PC remotely.
Which parameter should vary?
(like psexec: -i Interactive - Run the program so that it interacts with the desktop on the remote system.)
Thanks
  Mit Zitat antworten Zitat
haidomingo

Registriert seit: 22. Jul 2009
23 Beiträge
 
#5

Re: Start or end an application on a remote computer.

  Alt 26. Nov 2009, 15:23
I changed the code

Delphi-Quellcode:
....
Var
  ObjConf: ISWbemObject;
...

...
...

  Service.Security_.Set_ImpersonationLevel(wbemImpersonationLevelImpersonate);

  // added rows
     SObject:= Service.Get('Win32_ProcessStartup',0,nil);
     ObjConf := SObject.SpawnInstance_(0);
     PropValue := 1;
     objConf.Properties_.Item('ShowWindow',0).Set_Value(PropValue);


  SObject:= Service.Get('Win32_Process', 0, nil);
...
...
  MyProperty:= InParam.Properties_.Add('ProcessStartupInformation', wbemCimtypeObject, False, 0);
  // modified row
     PropValue:= ObjConf;
  MyProperty.Set_Value(PropValue);
but application does not appear into remote desktop PC
Help
  Mit Zitat antworten Zitat
Antwort Antwort


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 09:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz