Desligar o PC

leca

Membro
Boa noite

Sera que alguem sabe como eu posso programar o meu pc para se desligar a uma determinada hora(isto poquê, tenho happy hour da 1h as 7h e queria rentabilizar este facto).
Desde ja o meu mt obrigado a todos.
 
Há varios programas gratuitos...

Sou calão, podia fazer isso com algumas linhas de código, por isso saquei este programa que é gratuito: ShutDownOnTime

http://shutdownontime.ouvaton.org/

Já agora fica o código, que nem paciencia tenho para compilar... LOL

Código:
#TOKEN_ADJUST_PRIVILEGES  = $20
#TOKEN_QUERY              = $8
#EWX_POWEROFF             = $8

Structure NEW_LUID_AND_ATTRIBUTES
  pLuid.LUID
  Attributes.l
EndStructure

Structure NEW_TOKEN_PRIVILEGES
  PrivilegeCount.l
  Privileges.NEW_LUID_AND_ATTRIBUTES[#ANYSIZE_ARRAY]
EndStructure

Procedure.b DitchWindows (flags)
  DefType.OSVERSIONINFO
  os\dwOSVersionInfoSize = SizeOf (OSVERSIONINFO)
  GetVersionEx_ (os)
  If os\dwPlatformId = #VER_PLATFORM_WIN32_NT
    If OpenProcessToken_ (GetCurrentProcess_ (), #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @token)
      If LookupPrivilegeValue_ (#Null, "SeShutdownPrivilege", tkp.NEW_TOKEN_PRIVILEGES\Privileges[0]\pLuid)
        tkp\PrivilegeCount = 1
        tkp\Privileges[0]\Attributes = #SE_PRIVILEGE_ENABLED
        If AdjustTokenPrivileges_ (token, #False, tkp, #Null, #Null, #Null)
          If ExitWindowsEx_ (flags, 0) = 0
            ProcedureReturn 4
          EndIf
        Else
          ProcedureReturn 3
        EndIf
      Else
        ProcedureReturn 2
      EndIf
    Else
      ProcedureReturn 1
    EndIf
  Else
    If ExitWindowsEx_ (flags, 0) = 0
      ProcedureReturn 4
    EndIf
  EndIf
EndProcedure

Procedure.b System_LogOff (force)
  If force
    force = #EWX_FORCE
  EndIf
  flags = #EWX_LOGOFF | force
  ;DitchWindows (flags)
EndProcedure

Procedure.b System_ShutDown (force)
  If force
    force = #EWX_FORCE
  EndIf
  flags = #EWX_SHUTDOWN | force
  ;DitchWindows (flags)
EndProcedure

Procedure.b System_Reboot (force)
  If force
    force = #EWX_FORCE
  EndIf
  flags = #EWX_REBOOT | force
  ;DitchWindows (flags)
EndProcedure

Procedure.b System_PowerOff (force)
  If force
    force = #EWX_FORCE
  EndIf
  flags = #EWX_POWEROFF | force
  ;DitchWindows (flags)
EndProcedure
 
Back
Topo