Solution to Uac and Automatic startup in win7

Source: Internet
Author: User

During the use process, we will find that if you write the Exe with Uac into the Run of the registry, it cannot be automatically started upon startup, because the exe with Uac needs to apply for administrator permissions, in order to run the execution program, but cannot apply for administrator permissions at startup, Exe will not be able to start normally. So how to enable the Uac-enabled Exe to automatically start upon startup.
Since the Uac-enabled Exe cannot be applied for administrator permissions, you can create a new mini program without Uac. Can you solve the problem by applying for administrator permissions to start the exe? The implementation method is as follows:
Unit DyjStartMainForm;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI;
Const
WM_STARTCLOSE = wm_user+ 100;
Type
TFrmDyjStart = class (TForm)
Procedure FormCreate (Sender: TObject );
Private
{Private declarations}
Protected
Procedure WMStartClose (var Msg: TMessage); message WM_STARTCLOSE;
Public
{Public declarations}
End;
Var
FrmDyjStart: TFrmDyjStart;
Implementation
{$ R *. dfm}
Procedure TFrmDyjStart. FormCreate (Sender: TObject );
Begin
PostMessage (Self. Handle, WM_STARTCLOSE, 0, 0 );
End;
Procedure TFrmDyjStart. WMStartClose (var Msg: TMessage );
Var
_ VPathExe: string;
Begin
_ VPathExe: = ExtractFilePath (Application. ExeName) + 'sysreset.exe ';
ShellExecute (0, 'runas', PChar (_ vPathExe), nil, nil, SW_SHOWNORMAL );
Application. Terminate;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.