AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Run As system

Ein Thema von sdean · begonnen am 21. Nov 2012 · letzter Beitrag vom 21. Nov 2012
Antwort Antwort
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

Run As system

  Alt 21. Nov 2012, 12:55
Hello i've this code to launch an external Application as a system :
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  StartupInfo: TStartupInfoW;
  ProcessInformation: TProcessInformation;
begin
  ZeroMemory(@StartupInfo, SizeOf(TStartupInfoW));
  FillChar(StartupInfo, SizeOf(TStartupInfoW), 0);
  StartupInfo.cb := SizeOf(TStartupInfoW);
  StartupInfo.lpDesktop := 'WinSta0\Default';
  if CreateProcessAsSystemW(
    PWideChar(WideString(Edit1.Text)),
    PWideChar(WideString(Edit1.Text + ' -hi')),
    NORMAL_PRIORITY_CLASS,
    nil,
    nil,
    StartupInfo,
    ProcessInformation,
    SystemIntegrityLevel) then
  begin
    CloseHandle(ProcessInformation.hThread);
    CloseHandle(ProcessInformation.hProcess);
  end;
end;
my question is : how can i launch my application as a system , that's to say how to launch the application itself as a system instead of launching an external application .

many thanks
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.349 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Run As system

  Alt 21. Nov 2012, 14:36

By putting your application executable in as command instead of Edit1.Text? (ParamStr(0) )
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#3

AW: Run As system

  Alt 21. Nov 2012, 14:52

By putting your application executable in as command instead of Edit1.Text? (ParamStr(0) )
thank you , but what i meant is should i put it in the project.dpr if yes then should delete

Application.Initialize thank you again

Geändert von sdean (22. Nov 2012 um 14:43 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.349 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Run As system

  Alt 21. Nov 2012, 15:21
You can not give your running executable system access rights. You can only start a new instance of your executeble with those rights. And you could do so inside your project file if you want to.

But if you need to run in system context, why don't you just write a service application?
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#5

AW: Run As system

  Alt 21. Nov 2012, 15:31
You can not give your running executable system access rights. You can only start a new instance of your executeble with those rights. And you could do so inside your project file if you want to.
is that mean my application will have 2 different PIDs ?
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.349 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: Run As system

  Alt 21. Nov 2012, 16:19
The first instance can be closed, so only the second remains. But yes, your second instance will have a new PID and will be running separately from the first.

There is no other possibility.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  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 22:45 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