Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Elevate to Admin while runtime

It does not work...

I've tried the following:

Code
Private Sub aa()
      Dim wp = New WindowsPrincipal(WindowsIdentity.GetCurrent())
      If wp.IsInRole(WindowsBuiltInRole.Administrator) Then
      MessageBox.Show("Admin!")
      Else
      MessageBox.Show("Other User")
      End If
    End Sub

OS is Win 8.1.

Returns "Other User" although I have administrator rights.
(Nov 10, 2014 05:19 AM)Easi-- Wrote:  It does not work...

I've tried the following:

Code
Private Sub aa()
      Dim wp = New WindowsPrincipal(WindowsIdentity.GetCurrent())
      If wp.IsInRole(WindowsBuiltInRole.Administrator) Then
      MessageBox.Show("Admin!")
      Else
      MessageBox.Show("Other User")
      End If
    End Sub

OS is Win 8.1.

Returns "Other User" although I have administrator rights.

Try starting it as Administrator (right click -> start as Administrator)
If you have UAC activated windows still uses "Usermode"
[Image: uzpE9zW.jpg]

(Nov 10, 2014 05:19 AM)Easi-- Wrote:  It does not work...

I've tried the following:

Code
Private Sub aa()
      Dim wp = New WindowsPrincipal(WindowsIdentity.GetCurrent())
      If wp.IsInRole(WindowsBuiltInRole.Administrator) Then
      MessageBox.Show("Admin!")
      Else
      MessageBox.Show("Other User")
      End If
    End Sub

OS is Win 8.1.

Returns "Other User" although I have administrator rights.

That code doesn't check if the current account logged to windows has admin privileges, that checks if your application has them.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by gogglebotMay 26, 2018 08:48 PM 30 1,728 May 26, 2018 08:48 PM
Last Post: Erhan
[C#] by MalwareOct 16, 2014 08:07 PM 13 877 Oct 16, 2014 08:07 PM
Last Post: Malware
[.NET] by E3zh00rnApr 3, 2014 11:34 AM 3 149 Apr 3, 2014 11:34 AM
Last Post: E3zh00rn