title: How in Delphi can I run a command with administrator privileges?
body: <p>I am trying to stop mysql from Delphi XE2 on Win 7. I have written some code based on something I found on the web for Delphi 7, that was supposed to do this, but it doesn't  work:</p>
  
  <pre><code>function StopMySQL: boolean;
  const
    UserName = 'Mark';
    Domain = 'PC-Mark';
    Command = 'net stop mysql';
  var
    StartupInfo: TStartupInfo;
    ProcessInfo: TProcessInformation;
  begin
    FillChar(StartupInfo, SizeOf(StartupInfo), #0);
    StartupInfo.cb := SizeOf(StartupInfo);
    StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
    StartupInfo.wShowWindow := SW_HIDE;
    result := CreateProcessWithLogonW(Username, Domain, Password, 0, nil, Command, 0,     nil, nil, StartupInfo, ProcessInfo);
    if result then
      WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
  end;
  </code></pre>
  
  <p>Does anyone know how to do this?</p>
  
  <p>TIA
  Mark Patterson</p>