def win_shutdown():
 try:
  import win32security
  import win32api
  import ntsecuritycon
  flags = (ntsecuritycon.TOKEN_ADJUST_PRIVILEGES | ntsecuritycon.TOKEN_QUERY)
  htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), flags)
  id_ = win32security.LookupPrivilegeValue(None, ntsecuritycon.SE_SHUTDOWN_NAME)
  newPrivileges = [(id_, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
  win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges)
  win32api.InitiateSystemShutdown('', '', 30, 1, 0)
 finally:
  os._exit(0)

def win_shutdown ( ) : try : import win32security import win32api import ntsecuritycon flags = ( ntsecuritycon . TOKEN_ADJUST_PRIVILEGES | ntsecuritycon . TOKEN_QUERY ) htoken = win32security . OpenProcessToken ( win32api . GetCurrentProcess ( ) , flags ) id_ = win32security . LookupPrivilegeValue ( None , ntsecuritycon . SE_SHUTDOWN_NAME ) newPrivileges = [ ( id_ , ntsecuritycon . SE_PRIVILEGE_ENABLED ) ] win32security . AdjustTokenPrivileges ( htoken , 0 , newPrivileges ) win32api . InitiateSystemShutdown ( '' , '' , 30 , 1 , 0 ) finally : os . _exit ( 0 )
shutdown windows system .