def areAdminRightsElevated():
 pid = GetCurrentProcess()
 processToken = HANDLE()
 if (not OpenProcessToken(pid, TOKEN_READ, ctypes.byref(processToken))):
  raise ctypes.WinError()
 try:
  (elevated, elevatedSize) = (DWORD(), DWORD())
  if (not GetTokenInformation(processToken, TokenElevation, ctypes.byref(elevated), ctypes.sizeof(elevated), ctypes.byref(elevatedSize))):
   raise ctypes.WinError()
  return bool(elevated)
 finally:
  CloseHandle(processToken)

def areAdminRightsElevated ( ) : pid = GetCurrentProcess ( ) processToken = HANDLE ( ) if ( not OpenProcessToken ( pid , TOKEN_READ , ctypes . byref ( processToken ) ) ) : raise ctypes . WinError ( ) try : ( elevated , elevatedSize ) = ( DWORD ( ) , DWORD ( ) ) if ( not GetTokenInformation ( processToken , TokenElevation , ctypes . byref ( elevated ) , ctypes . sizeof ( elevated ) , ctypes . byref ( elevatedSize ) ) ) : raise ctypes . WinError ( ) return bool ( elevated ) finally : CloseHandle ( processToken )
tells you whether current script already has administrative rights .