title: Why can't I start the Windows Update control panel with WinExec?
body: <p>In <a href="http://msdn.microsoft.com/en-us/library/cc144191.aspx" rel="nofollow noreferrer"><em>Executing Control Panel Items</em></a>, MSDN says this:</p>
  <blockquote>
  <p><strong>Windows Vista Canonical Names</strong></p>
  <p>In Windows Vista and later, the preferred method of launching a Control Panel item from a command line is to use the Control Panel item's canonical name.</p>
  </blockquote>
  <p>According to the Microsoft website this should work:</p>
  <blockquote>
  <p>The following example shows how an application can start the Control Panel item Windows Update with WinExec.</p>
  <pre><code>WinExec(&quot;%systemroot%\system32\control.exe /name Microsoft.WindowsUpdate&quot;, SW_NORMAL);
  </code></pre>
  </blockquote>
  <p>For Delphi 2010 I tried:</p>
  <pre><code>var
    CaptionString: string;
    Applet: string;
    Result: integer;
    ParamString: string;
  CaptionString := ListviewApplets1.Items.Item[ ListviewApplets1.ItemIndex ].Caption;
  if CaptionString = 'Folder Options' then
      { 6DFD7C5C-2451-11d3-A299-00C04F8EF6AF }
      Applet := 'Microsoft.FolderOptions'
    else if CaptionString = 'Fonts' then
      {93412589-74D4-4E4E-AD0E-E0CB621440FD}
      Applet := 'Microsoft.Fonts'
    else if CaptionString = 'Windows Update' then
      { 93412589-74D4-4E4E-AD0E-E0CB621440FD }
      Applet := 'Microsoft.WindowsUpdate'
    else if CaptionString = 'Game Controllers' then
      { 259EF4B1-E6C9-4176-B574-481532C9BCE8 }
      Applet := 'Microsoft.GameControllers'
    else if CaptionString = 'Get Programs' then
      { 15eae92e-f17a-4431-9f28-805e482dafd4 }
      Applet := 'Microsoft.GetPrograms'
  //...
  
  ParamString := ( SystemFolder + '\control.exe /name ' ) + Applet;
  WinExec( ParamString, SW_NORMAL); &lt;= This does not execute and when I trapped the error it returned ERROR_FILE_NOT_FOUND.
  </code></pre>
  <p>I tried a ExecAndWait( ParamString ) method and it works perfectly with the same ParamString used with WinExec:</p>
  <pre><code>ParamString := ( SystemFolder + '\control.exe /name ' ) + Applet;
  ExecAndWait( ParamString ); &lt;= This executes and Runs perfectly
  </code></pre>
  <p>The ExecAndWait method I used calls Windows.CreateProcess:</p>
  <pre><code>if Windows.CreateProcess( nil, PChar( CommandLine ), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo ) then
    begin
      try
  </code></pre>
  <p>Does WinExec require a different ParamString, or am I doing this wrong with WinExec?  I did not post the full ExecAndWait method but I can if someone wants to see it.</p>