WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Problem mit CreateProcess (C/Win32-API) (http://www.wcm.at/forum/showthread.php?t=116879)

Sonic 27.11.2003 13:43

Problem mit CreateProcess (C/Win32-API)
 
Hallo!

Ich hab ein Win32 Consolen Programm geschrieben das als Scheduled Task laufen soll und, unter anderem, automatisch Zip files mit hilfe eines externen packprogramms erstellt.

Das ganze funktioniert, wenn ich das Programm auf der Console starte, wunderbar.
Jedoch wenn es als Scheduled Task startet bekomme ich beim CreateProcess eine Windows Fehlermeldung (Messagebox) mit folgender Fehlermeldung:

"The Application failed to initzialize properly.
Click OK to terminate the aplication."

Ich hab im Moment leider keine Ahnung woran es liegen könnte und hoffe das jemand von euch rat weiß!

Wäre für jeden Rat dankbar!

Code zum Zippen:
PHP-Code:


/*** Function CompressFile ***\
exepath        Path of the zip executable
source        source directory where the file to be compressed lies
dest            destination path where compressed file will be put
name            source filename
password    password for encryption
returns 999 if the process could not be created or the returncode of the zip programm
*/

#define ZIP_COMPRESS_FORMAT "%s -add -lev=9 -silent -move -pass=%s \"%s%s.zip\" \"%s%s\""
#define ZIP_COMPRESS_FORMAT_LEN 56

int CompressFile(char *exepath,char sourcechar *destchar *namechar *password)
{
    
STARTUPINFO sti;
    
PROCESS_INFORMATION pri;
    
char *cmdline;
    
DWORD exitcode;

    
//Assemble Commandline
    
cmdline=(char*)malloc(sizeof(char)*(ZIP_COMPRESS_FORMAT_LEN+1+strlen(exepath)+strlen(source)+strlen(dest)+strlen(password)+strlen(name)*2));
    
sprintf(cmdline,ZIP_COMPRESS_FORMAT,exepath,password,dest,name,source,name);

    
memset(&sti,0,sizeof(STARTUPINFO)); 
    
sti.cb=sizeof(STARTUPINFO);
    
sti.lpDesktop="";

    if (
CreateProcess(NULLcmdline,NULLNULL0NORMAL_PRIORITY_CLASSNULLNULL, &sti, &pri))
    {
        
//Wait till process has finished
        
WaitForSingleObjectpri.hProcessINFINITE );
        
//And save the exitcode to be returned
        
GetExitCodeProcess(pri.hProcess, &exitcode);
        
        
//Cleanup
        
CloseHandlepri.hProcess );
        
CloseHandlepri.hThread );
        
free(cmdline);
        return 
exitcode;
    }
    else
    {
        
//The process could not be created
        
free(cmdline);
        return 
999;
    }


LG

JackLemon 28.11.2003 00:19

unter welchem benutzer startest du den prozess? hat er das privileg "anmelden als dienst"? kannst du andere programme als scheduled task starten? schreibt srvany was ins ereignis-protokoll?

-JL

Sonic 28.11.2003 10:50

Hab das Privileg "anmelden als dienst" vergeben, hat aber leider nichts geholfen. :( Im Ereigniss-Protokoll steht leider auch nichts drinnen.

Egal wasfürein Programm ich aus dem Task heraus starte es kommt immer diese Fehlermeldung. Es liegt also nicht am ZIP Programm.

lg

Flink 28.11.2003 13:34

Gib doch einmal über printf deine Parameter aus!

Sonic 01.12.2003 11:12

Mit den Parametern passt soweit alles.
Es funktioniert ja auch wenn ich es "händisch" also auf der Console starte.
Der Fehler tritt nur auf wenn ichs als Scheduled Task laufen lass. :(

Flink 01.12.2003 11:50

Hast du CreateProcess mit den richtige Parameter-Werten aufgerufen :confused:


Alle Zeitangaben in WEZ +2. Es ist jetzt 10:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag