Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Startup computer automatically

Startup computer automatically

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sschilachi
    wrote on last edited by
    #1

    Is there any way to boot up a computer automatically at a specific time from a program, ie run the program, call a function (???) and then switch off the computer, and then the computer would start up automatically at the specified time. If not then is there some way of bringing the computer out of hibernation in a similar way??? Thanks

    M L B 3 Replies Last reply
    0
    • S sschilachi

      Is there any way to boot up a computer automatically at a specific time from a program, ie run the program, call a function (???) and then switch off the computer, and then the computer would start up automatically at the specified time. If not then is there some way of bringing the computer out of hibernation in a similar way??? Thanks

      M Offline
      M Offline
      Mika Larramo
      wrote on last edited by
      #2

      I'm not sure what you mean, but if you mean to restart a computer at specified time it is possible of course. Below you have a function for rebooting the computer. It works with all Windows versions. Call it with the in parameter EWX_REBOOT and the system will be rebooted: BOOL WindowsExitOrReboot(UINT flags) { if (IsWindowsNT()) { // Windows NT etc HANDLE hToken; TOKEN_PRIVILEGES tkp; // Reset last error SetLastError(ERROR_SUCCESS); // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE; // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); // Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS) return FALSE; // Shut down the system and force all applications to close. if (!ExitWindowsEx(flags | EWX_FORCE, 0)) return FALSE; return TRUE; } else { // Windows 95 etc if (!ExitWindowsEx(flags, 0)) return FALSE; return TRUE; } } But if you mean to shut down the computer for a time and then let it start automatically I don't think it is possible. Not without some hardware.

      S 1 Reply Last reply
      0
      • S sschilachi

        Is there any way to boot up a computer automatically at a specific time from a program, ie run the program, call a function (???) and then switch off the computer, and then the computer would start up automatically at the specified time. If not then is there some way of bringing the computer out of hibernation in a similar way??? Thanks

        L Offline
        L Offline
        lonely_life
        wrote on last edited by
        #3

        personally, I think you need a external device & program to control the power supply of shut down pc.

        1 Reply Last reply
        0
        • M Mika Larramo

          I'm not sure what you mean, but if you mean to restart a computer at specified time it is possible of course. Below you have a function for rebooting the computer. It works with all Windows versions. Call it with the in parameter EWX_REBOOT and the system will be rebooted: BOOL WindowsExitOrReboot(UINT flags) { if (IsWindowsNT()) { // Windows NT etc HANDLE hToken; TOKEN_PRIVILEGES tkp; // Reset last error SetLastError(ERROR_SUCCESS); // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE; // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); // Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS) return FALSE; // Shut down the system and force all applications to close. if (!ExitWindowsEx(flags | EWX_FORCE, 0)) return FALSE; return TRUE; } else { // Windows 95 etc if (!ExitWindowsEx(flags, 0)) return FALSE; return TRUE; } } But if you mean to shut down the computer for a time and then let it start automatically I don't think it is possible. Not without some hardware.

          S Offline
          S Offline
          sschilachi
          wrote on last edited by
          #4

          I actually meant is there any way to turn the computer on automatically at a specific time, when it has been turned off manually. For example could I program the computer to boot up at 8 o'clock every morning? If not, is there any way to bring the computer out of standby mode in the same way, ie bring the computer out of standby at 8 o'clock every morning. Thanks

          T 1 Reply Last reply
          0
          • S sschilachi

            I actually meant is there any way to turn the computer on automatically at a specific time, when it has been turned off manually. For example could I program the computer to boot up at 8 o'clock every morning? If not, is there any way to bring the computer out of standby mode in the same way, ie bring the computer out of standby at 8 o'clock every morning. Thanks

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Hain i think you are seaching for wake on Lan feature type application. i am able to boot computer through network at giving time. bascially it functioning is like this-> You send a packet containg the subnet mask of you network to that particular computer which is in off state this feature only feasible for ATX cabinet computer & lan card with wake on lan feature Happy programming ----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

            1 Reply Last reply
            0
            • S sschilachi

              Is there any way to boot up a computer automatically at a specific time from a program, ie run the program, call a function (???) and then switch off the computer, and then the computer would start up automatically at the specified time. If not then is there some way of bringing the computer out of hibernation in a similar way??? Thanks

              B Offline
              B Offline
              bmw5002
              wrote on last edited by
              #6

              No its not possible. That is set in the bios, and you have no programmatical access to the bios.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups