기타 [vb.net] 관리자 권한으로 실행하기
페이지 정보
본문
Imports System.Security.Principal
Module Program
Sub Main()
If IsAdministrator() = False Then
Try
Dim procInfo As New ProcessStartInfo()
procInfo.UseShellExecute = True
procInfo.FileName = Application.ExecutablePath
procInfo.WorkingDirectory = Environment.CurrentDirectory
procInfo.Verb = "runas"
Process.Start(procInfo)
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try
Return
End If
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Dim F As Form = TGauge.Main
F.ShowDialog()
End Sub
Public Function IsAdministrator() As Boolean
Dim identity As WindowsIdentity = WindowsIdentity.GetCurrent()
If identity IsNot Nothing Then
Dim principal As New WindowsPrincipal(identity)
Return principal.IsInRole(WindowsBuiltInRole.Administrator)
End If
Return False
End Function
End Module
- 이전글[vb.net] 하드(HDD) 시리얼 넘버(hard drive serial number) 가지고 오기 19.07.13
- 다음글[vb.net] 크롬이 열려 있으면 새창으로 열기 19.07.08
댓글목록
등록된 댓글이 없습니다.