Saturday, August 15, 2015

Automatically Turn Off Your Computer. Windows shutdown app. Shutdown Timer. Free download, C source code

For your reasons you want to shutdown your computer after minutes or an hour, etc.
With this simple app you can shutdown your computer in a very simple way.

1. Execute the program
2. Give the minutes you want your computer to shutdown
3. That is all. The computer will automatic shutdown


Download here



Otherwise you could run CMD (Command Prompt)

C:\> shutdown -s -t 180    -Enter-
-s   means shutdown computer
-t   means after how many seconds will execute the command
180 are the seconds after that will the computer shutdown
 --------------------------------
C:\> shutdown -a      -Enter-
-a   mean abort the shutdown execution
with this command you will abort shutdown



------------------------------------
------------------------------------



-----------------------------------
C Code after this line
-----------------------------------
#include <stdio.h>
#include <time.h>
#include <windows.h>






//delay code-block
void delay (unsigned int secs) {
    unsigned int retTime;
    retTime = time(0) + secs;     // Get finishing time.
    while (time(0) < retTime);    // Loop until it arrives.
}





int main()
{
    int i;
    int minutes;
    int flag=0;
   
    minutes=0;
   
   
       
       
    printf ("Give minutes to Shutdown: ");
    scanf("%d", &minutes);
    minutes= minutes *60;




    delay(minutes-30);       
    printf("Remaining 30 secs\n");
    delay(20);
   
   
    printf ("Remaining less than 10 seconds, press continuously ESC to abort\n");
    for (i=10;i>=0;i--)
    {
        delay(1);        //delay 10 seconds
        printf("\n");
        printf("Remaining secs: %d", i);


       
        if(GetAsyncKeyState(VK_ESCAPE ) < 0)
        {
            flag=1;
            break;
        }
       
    }
   
    if (flag==0)
        system("shutdown /s");
    return 0;
}

No comments:

Post a Comment