16-03-14, 01:06 PM
هذا الكود يغلق البرنامج ثم يعيد بدئه كمسؤول:
كما يمكنك إضافة ملف صغير بجانب برنامجك ينفذ هذا الأمر فقط و يبدأ كمسؤول عندما يأمره برنامجك بذلك.
PHP كود :
Dim isEleveted As Boolean
Dim identity As Security.Principal.WindowsIdentity = Security.Principal.WindowsIdentity.GetCurrent()
Dim principal As New Security.Principal.WindowsPrincipal(identity)
isEleveted = principal.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator)
If Not isEleveted Then
If MsgBox("Do you want to run as an administrator?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Dim P As Process = Process.GetCurrentProcess
Dim SF As New Diagnostics.ProcessStartInfo
SF.FileName = Application.ExecutablePath
SF.Verb = "runas"
P.StartInfo = SF
P.Start()
End If
Application.Exit()
End If
كما يمكنك إضافة ملف صغير بجانب برنامجك ينفذ هذا الأمر فقط و يبدأ كمسؤول عندما يأمره برنامجك بذلك.

