How does the program request administrator rights?

I am working on a small application in VB.NET. To perform some tasks, the program requires administrator privileges. Is there a way to request administrator rights at runtime if the program?

What is the general way to change the user account under which the application is running?

+3
source share
4 answers

Depending on your needs, there are a number of methods. Some details are provided in the requirements of the application developer for UAC .

  • Enable the UAC manifest, which forces your program to require administrator rights at startup.
  • . - - CoCreateInstanceAsAdmin COM-, . , VB.Net. ++,
  • ok , , , , UAC, . . admin privilegese, .
+3

.

.

+7
 Try
                    Dim procInfo As New ProcessStartInfo()
                    procInfo.UseShellExecute = True
                    procInfo.FileName = 'Filename here
                    procInfo.WorkingDirectory = ""
                    procInfo.Verb = "runas"
                    Process.Start(procInfo)
                Catch ex As Exception
                    MsgBox(ex.Message.ToString(), vbCritical)
                End Try
            End If
+1

- "" β†’ Windows Form β†’ .XML β†’ ( ).manifest β†’ link ( JDOConal) β†’ β†’ , .manifest β†’ build = done!

0

Source: https://habr.com/ru/post/1697104/


All Articles