ó
ÉŻ{Tc           @   sŌ   d  d l  Z  d  d l Z d  d l  Td  d l Td Z d e f d     YZ e d  Z e d k rŠ e	 e j
  d k  r e j   n  e j
 d Z d	 GHe j j   e e e j
 d d
 e d GHe j j   n  d S(   i’’’’N(   t   *i   t   SHELLEXECUTEINFOc           B   s   e  Z d  e f d e f d e f d e f d e f d e f d e f d e f d e f d	 e f d
 e f d e	 f d e f d e
 f d e
 f g Z RS(   t   cbSizet   fMaskt   hwndt   lpVerbt   lpFilet   lpParameterst   lpDirectoryt   nShowt   hInstAppt   lpIDListt   lpClasst	   hkeyClasst   dwHotKeyt   hIconMonitorUniont   hProcess(   t   __name__t
   __module__t   DWORDt   ULONGt   HWNDt   LPCWSTRt   c_intt	   HINSTANCEt   LPVOIDt   HKEYt   HANDLEt   _fields_(    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/util/Win32RunAsAdmin.pyR      s   														c   	      C   s?  d } x | D] } | d | } q Wt  j j j   } t   } t  j |  | _ d | _ d | _ d | _	 |  | _
 | | _ d | _ t | _ |  GH| GH| r­ d | _	 n	 d | _	 t  j j j t |   } | r;| j d k r;| j r;| r;d	 GHt j j   t  j j j | j d
  } d G| GHt j j   n  d  S(   Nt    t    i    i   i@   t   opent   runasi    t   waitingl   ’’ s	   waited!!!i@  (   t   ctypest   windllt   shell32t   IsUserAnAdminR   t   sizeofR   R   R   R   R   R   R   t   SW_SHOWNORMALR	   t   ShellExecuteExWt   byrefR
   R   t   syst   stdoutt   flusht   kernel32t   WaitForSingleObject(	   t   cmdt   argst   blockt   commandLinet   argt	   isanadmint   seist   rett   waitret(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/util/Win32RunAsAdmin.pyt   RunAsAdministrator   s2    									$ 	 t   __main__i   s   Doing commandR1   s   Done command(   R"   R*   t   ctypes.wintypesR'   t	   StructureR   t   FalseR8   R   t   lent   argvt   exitR/   R+   R,   t   True(    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/util/Win32RunAsAdmin.pyt   <module>   s   

   