Unanswered uac aware application

  • Freitag, 27. Juli 2012 11:13
     
     

    I have application written in VB6(let us say A). This application calls another application(let us say B) and runs it. The application "B" does some functions like copying of dll files etc .This application requires administrative privileges.My application has digital signature also.

    When i run application "A" and when it calls application "B", the "B" fails to copy files which are required to be copied bcoz the application doesn't have administrative privilege.When i close software i get a UAC prompt saying run as administrator.Now if i click yes then application can do copying files etc.This problem is only in vista and windows 7 bcoz it has UAC.I think i want to run my application as administrator to solve this.So how can i do it in VB6? Is there any method so that UAC does not prompt for my application. Please help to avoid UAC prompt and also to run it as administrator.

     

Alle Antworten

  • Montag, 30. Juli 2012 04:03
    Moderator
     
      Enthält Code

    No, the UAC should prompt if your code request to run as Admin. Please do not close the prompting. The UAC is to let the user, not the programmer, control the computer. Please let the user to select this action if your code can access the UAC protected resources. http://blogs.msdn.com/b/oldnewthing/archive/2010/03/11/9976571.aspx

    And for calling the process run as admin, you could use the parameter "runas".

    Private Declare Function ShellExecute Lib "shell32" _
        Alias "ShellExecuteA" ( _
        ByVal hWnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As VbAppWinStyle) As Long
        
    ....
        
    ShellExecute hWnd, "runas", B.EXEName & ".exe", ...


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

  • Samstag, 18. August 2012 06:40
     
     
    My application copies some of .dll file into system32 folder. i think because of this UAC prompt shows up for my application. How can i avoid showing up of UAC prompt for an application?
  • Montag, 20. August 2012 10:24
    Moderator
     
     
    Please do not change the system setting to avoid UAC prompt yourself, let your customers and users do it. And you could change the UAC promp level to low from Control Panel > System and Security > Action Center > Change User Account Control settings, to Never notify.

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

  • Dienstag, 21. August 2012 10:17
     
     
    We developed a application in which it copies only some dll files which are required to run the application. We do not change any system settings.We just copy files  which requires to run our application.
  • Dienstag, 21. August 2012 10:37
    Moderator
     
     

    To copy the files to the system key position, it needs to request the admin right, and should promp the UAC dialog, otherwise, it is an unsafe operation.

    I have answered, we have to run it as admin, or you could try to config the Shim (http://blogs.technet.com/b/askperf/archive/2010/08/27/act-suppressing-elevation-prompts-for-legacy-applications.aspx), but it is complex for this simple requirement.

    So I suggest to run your application as admin for oprtate the files in system folder and let the system to promp the UAC dialog.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

  • Freitag, 5. Oktober 2012 11:09
     
     
    I agree with Bob Bao...But As i said before if i create a application let us say A and that application calls another application(let us say B) in some rare cases. The application B copies some dll files. So it requires administrative permissions. but application A doesn't copy any files or anything else. So can i create application A without UAC prompt displaying for it(bcoz it does not change any system configuration)? Let the UAC prompt only for application B which requires administrative permission.Can i do this anyway?
  • Samstag, 20. Oktober 2012 04:54
     
     
    Anyone please reply me.