I am working on a small application in VB.NET.
The program needs administrator privilege for doing some tasks.
Is there a way to ask for administrator privileges during the execution if the program?
What is the general way of changing the user account under which the application is running?

Actually What I want to Do?
I am Having one Form in which there is "Download Button" and by clicking this button it will open "updatedownloader" which I want to run as admin, I don't want the Program to restart as by doing so I will not able to save some of text, images, audio etc

Those who knows please send me reply with solution.
Fast

What is the general way of changing the user account under which the application is running?

The general way is to restart the application under elevated privileges:

Private Sub ElevateMe()
    Dim proc As new ProcessStartInfo()

    proc.UseShellExecute = True
    proc.WorkingDirectory = Environment.CurrentDirectory
    proc.FileName = Application.ExecutablePath
    proc.Verb = "runas"

    Try
        Process.Start(proc)
    Catch
        Exit Sub
    End Try

    Application.Exit() ' Kill the old process
End Sub

Permissions are done on a per process basis, so while you can demand admin rights at a higher granularity, it would require the application to originally be started as an admin in the first place.

I don't want the Program to restart as by doing so I will not able to save some of text, images, audio etc

Why not? Save the current state of the program and then reload it when the new process starts.

Isn't that possible that the new form will start as admin..
IF the current form is not admin then the new form will ask for permission and yes then it will load Else no.

A form is not a process. You can wrap it in a process, after a fashion, but that would sever any connection with the calling form and process.

This article has been dead for over six months. Start a new discussion instead.