1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
FILE *P_File;
int location;
int i; /* Variable de controle */
char tcp[104];
char printname[50];
char print[100];
char printnumber[3];
char addressip[15];
char batfile[12] = "install.bat";
/* Construction de l'adresse IP */
strcpy(addressip, "192.168.");
printf("What is your location?\nPress '1' for HEROS \nPress '2' for Jargo\nThen press enter\n");
scanf("%d", &location);
strcpy(printname, "HP Color LaserJet 3800 - ");
if (location!=1.0)
{ strcat(printname, "JAR ");}
switch (location)
{
case 1:
strcat(addressip, "1.");
break;
case 2:
strcat(addressip, "9.");
break;
default:
printf("\nERROR");
return 0;
}
printf("\nWhat is the number of the printer you wish to install?\n(Enter only the last three number)\n");
scanf("%s", &printnumber);
strcat(addressip, printnumber);
strcat(printname, printnumber);
printf("\nIP address = %s% \n Printer name = %s% \n", addressip,
printname);
/* Creation du port TCP/IP pour imprimante puis ecriture dans le bat
*/
strcpy(tcp, "cscript C:\\WINDOWS\\system32\\prnport.vbs -t -r IP_");
strcat(tcp, addressip);
strcat(tcp, " -o raw -n 9100 -h ");
strcat(tcp, addressip);
strcat(tcp, " -me -2e");
printf("\nCreation du port 243\nla ligne de commande sera:\n%s", tcp);
P_File = fopen(batfile, "w");
fprintf(P_File, "%s%\n", tcp);
fclose(P_File);
/* Installation d'une 3800 */
strcpy(print, "rundll32 printui.dll,PrintUIEntry /if /b \"");
strcat(print, printname);
strcat(print,"\" /f \\\\server\\share\\Printers_Drivers\\HP_3800\\hpc3800c.inf /r \"IP_");
strcat(print, addressip);
strcat(print, "\" /m \"HP Color LaserJet 3800 PCL 6\" /z");
printf("\nInstallation de l'impr sur port xxx:\n%s", print);
/* ecriture ds le futur bat */
P_File = fopen(batfile, "r+");
fseek(P_File, 0, SEEK_END);
fprintf(P_File, "%s", print);
fclose(P_File);
i = system ("install.bat");
/* remove("install.bat");
return 0;
*/
} |
Partager