De modo urgente me tengo que poner a leer algo de C/C++, muy agradecido siempre con este foro y con todos los que me ayudan, de todas formas nunca pude setear el pass de forma "automatica".
PD: Felices Fiestas!
Comparto código resuelto:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main()
{
FILE *fp;
char filename[30]; //filename for source code
// starting header of outputted file
char header[300] = "/*\nBatch DOS command To C source Converter\nBy sam207 (samar_acharya[at]hotmail.com)\nhttp://www.sampctricks.blogspot.com\nhttp://nepali.netau.net\n*/\n";
//all the includes in output file
char incs[200] = "#include <stdio.h>\n#include <conio.h>\n#include <stdlib.h>\n#include <windows.h>\nint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,\nPSTR szCmdLine, int iCmdShow)\n{\n";
//end part of output file
char end[50] = "\treturn 0;\n}";
//for command
char cmd[150];
//para el resto, la clave
char cmb[350];
printf("\t+----------------------------+\n");
printf("\t|BATCH TO C SOURCE CONVERTER |\n");
printf("\t|CODED BY SAMARDHWOJ ACHARYA |\n");
printf("\t+----------------------------+\n");
printf("\nEnter the filename(with .c extension): ");
scanf("%s",filename);
printf("\nContraseña: ");
scanf("%s",cmb);
fp = fopen(filename,"w");
if (fp==NULL)
{
printf("Some error occurred while opening file");
getch();
exit(1);
}
else
{
fprintf(fp,"%s%s",header,incs);
fprintf(fp,"char clave[6];\n");
fprintf(fp,"printf(\"escriba su clave: \");\n");
fprintf(fp,"scanf(\"%%s\",clave);\n");
fprintf(fp,"if(strcmp(clave,\"%s\")==0)\n",cmb);
fprintf(fp,"{\n");
printf("\nNow start entering DOS commands: \n");
printf("When finished, type 'end' for the end of commands\n");
printf("\nStart:\n\n");
gets(cmd);
while (1)
{
gets(cmd);
if (!strcmp(cmd,"end"))
{
break; //if end is typed, get out of loop
}
fprintf(fp,"\tsystem(\"%s\");\n",cmd);
}
fprintf(fp,"\tprintf(\"\\n\");\n");
fprintf(fp,"\t}\nelse\n{\n");
fprintf(fp,"\tprintf(\"Clave no valida\");\n}\n");
fprintf(fp,"\n%s",end);
printf("\n\nFile successfully created");
printf("\nNow compile it with any C compiler");
printf("\nThanks for using this little app");
fclose(fp);
}
getch();
}