Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to shutdown my windows 7/xp after 30 min automatically by using shortcut, how do i create shortcut which will ask me time limit and after that time limit it will shutdown windows 7/xp automatically.

share|improve this question

migrated from stackoverflow.com Jun 27 '13 at 21:58

This question came from our site for professional and enthusiast programmers.

    
A shortcut alone cannot do that. The shortcut needs to run a separate application that then prompts you, then keeps track of the time, and issues the shutdown when appropriate. –  Remy Lebeau Jun 27 '13 at 18:07
    
This is not a programming question, and is off-topic here. Operating system and general computer questions belong on Super User instead. –  Ken White Jun 27 '13 at 19:40
    
You can write a batch file for this, or else there are lots of GUI apps that allow you to specify the time to shutdown/sleep/logoff/whatever. –  Karan Jun 27 '13 at 22:04

2 Answers 2

Even easier way to do it:
Create a shortcut with the target: shutdown /s /f /t 1800

That will cause the computer to reboot after 1800 seconds, and also to force any open applications to close (WARNING: The /f switch will cause you to lose any unsaved data). I use something similar to reboot my work laptop and servers remotely, using this same command.

share|improve this answer
1  
You may want to to add the /f switch to force open applications to shutdown. From a command prompt run shutdown /? to see all the switches. –  Keltari Jun 28 '13 at 14:30
    
@Keltari That is an excellent suggestion, I'll update my answer with that information. –  Taegost Jun 28 '13 at 14:40

Compile this C program and and the exe file is the one that you are looking for.. if u like this select this as answer..

#include <time.h>
#include <stdio.h>
main() { 
    int hour,minutes;
    long int total;
    printf("\nEnter the no.of.hours and minutes for shuting down:");
    scanf(" %d %d",&hour,&minutes);
    total = hour*60*60 + minutes*60; 
    sleep(total);
    system("C:\\windows\\system32\\shutdown /s /t 10");
    return 0;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.