Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Version 0.9
- Usage - shutdowner hh:mm r, where r is restart. r is optional, if you use shutdowner without r, the computer will be shutdown at the selected time.
- Updated 5 january 2013
- Author: Ion Prodan
- */
- #include <string.h>
- #include <stdio.h>
- #include <windows.h>
- #include <wchar.h>
- #include <unistd.h>
- #define sleep(x) Sleep(1000 * x)
- int checkTime();
- int main ( int argc, char *argv[] ) {
- char getCheckTime;
- getCheckTime = 'r';
- char *getFirstArgument = argv[1];
- char *getSecondArgument = argv[2];
- checkTime(&getCheckTime);
- //printf( "%s", getCheckTime);
- while(*getFirstArgument != getCheckTime) {
- sleep(1);
- checkTime(&getCheckTime);
- }
- if(*getSecondArgument == 'r') {
- system("shutdown /r");
- } else {
- system("shutdown /s");
- }
- checkTime(getCheckTime);
- printf("%d\n", getCheckTime);
- return 0;
- }
- int checkTime() {
- char getConvertedTime[5] = {};
- SYSTEMTIME localTime;
- GetLocalTime ( &localTime );
- sprintf( getConvertedTime, "%d:%d", localTime.wHour, localTime.wMinute );
- return *getConvertedTime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement