*.cmd Programm ausführen lassen
-
Hallo Leutz
Kann mir vielleicht einer sagen, warum beim ausführen dieses programmes die Fehlermeldung "Bad command or file name" kommt??
#include <stdio.h> #include <conio.h> #include <stdlib.h> main() { clrscr(); int c; FILE *ptr; ptr = fopen("c:\\ansic\\test.cmd","w"); if(0 == ptr) printf("Konnte Datei test.cmd nicht oeffnen!\n"); else { printf("Super. Datei geoeffnet!\n"); } fprintf(ptr, "shutdown -l"); printf("LOG OFF!"); fclose(ptr); system("c:\\ansic\\test.cmd"); return 0; }
-
"c:\\ansic\\test.cmd" muß eine .exe oder .com datei sein. sonst funtioniert system() nicht.
EDIT: das gilt natürlich nur für windows.
-
OK
aber wie öffne ich eine *.cmd Datei????
wie kann ich das anstellen?
danke
mfg
-
system("cmd.exe /C c:\\ansic\\test.cmd"); // <- geht das?
-
danke vielmal!!!
es funktioniert!!!