well hi this is my second thread the first one still unsolved lets see about this one.

how can i do that when my program is open and its run in a Vista computer, it have to show a MsgBox and says Error please run as admin and when it is run as admin it wont appear ?

XP don't need to open as admin


P.S sorry for my English. and I'm sorry that i didn't explain good.(i think)

Recommended Answers

All 2 Replies

to require admin privileges add into your app.manifest this line
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

to check for privileges:

if not My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) then
msgbox "Sorry you have to be an administrator"
end if
commented: Thank you for solving my problem. +1

to require admin privileges add into your app.manifest this line
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

to check for privileges:

if not My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) then
msgbox "Sorry you have to be an administrator"
end if

i didn't put the line

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

i just do this

Dim MymessageBox2
From load
If Not My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then
            MymessageBox2 = MsgBox("Please Run as Administrator", MsgBoxStyle.Critical)
            If MymessageBox2 = MsgBoxResult.Ok Then
                Me.Close()

Thank you my problem is solve :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.