C++ (komenda at, shutdown) czemu nie działa?

0

Witam serdecznie ;)
Zastanawiam się dlaczego mój kod nie chce odpalać prawidłowo. Powinno działać. Prosiłbym o sprawdzenie lub nakierowanie.

#include <iostream>
#include <conio.h>
#include <string>
// Program wylacza komputer o podanej godzinie...
using namespace std;
int main(int *argc, char argv[])
{
    string czas;
    string czas2;
    cout << "Podaj czas o ktorej komputer ma zostac wylaczony: " << endl;
    cin >> czas;
    czas2 = czas;
    czas = "at "+czas+" /interactive \"shutdown -t 0\"";         
    system(czas.c_str());
    cout << "Komputer zostanie wylaczony o godzinie: "<<czas2<<endl
    << "kliknij aby zakonczyc!"<<endl;
    getch();
}

0

Ale na jakim systemie wg ciebie to powinno zadzialać? Bo na moje oko to tylko na linuxie jakimś

0

Pod linuxem masz takie coś:

Sposób użycia: shutdown [OPCJA]... CZAS [WIADOMOŚĆ]
Zamknięcie systemu.

Opcje:
-r reboot after shutdown
-h halt or power off after shutdown
-H halt after shutdown (implies -h)
-P power off after shutdown (implies -h)
-c cancel a running shutdown
-k only send warnings, don't shutdown
-q, --quiet reduce output to errors only
-v, --verbose increase output to include informational messages
--help display this help and exit
--version output version information and exit

TIME may have different formats, the most common is simply the word 'now' which
will bring the system down immediately. Other valid formats are +m, where m is the
number of minutes to wait until shutting down and hh:mm which specifies the time on
the 24hr clock.

zrób komendę, i wyślij ją system()'

0

Na windowsie xp musiałoby zadziałać.. jak wysyłam shutdown do system() z at to nie chce odpalić. Ale nie wiem czemu np. na logoff działa..

0

shutdown -s -t 0

EDIT:
Gelldur obie wersje sa poprawne w Windows :

0

wygląda to tak system("shutdown /s /t 0"); lub poszukaj jak jest wyłączenie systemu Od razu nawet bez czekania az programy sie wylaczą

1 użytkowników online, w tym zalogowanych: 0, gości: 1