I would like to know how to invoke the Windows Security Dialog (press ctrl+alt+del on a windows workstation NOTE: I don\'t want the task manager!) programmatically.
This is a workaround i found on other forum. It works for me.
Private Function IsRunAsAdministrator() As Boolean
Dim wi = WindowsIdentity.GetCurrent()
Dim wp = New WindowsPrincipal(wi)
Return wp.IsInRole(WindowsBuiltInRole.Administrator)
End Function
'i use it on formload, you can have it whenever needed
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsRunAsAdministrator() Then
Dim processInfo = New ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase)
processInfo.UseShellExecute = True
processInfo.Verb = "runas"
Try
Process.Start(processInfo)
Catch ew1 As Exception
MessageBox.Show("Sorry, this application must be run as Administrator.")
End Try
'Application.Current.Shutdown()
Application.ExitThread()
Else
'your statement here
End If
End Sub