Code:
#include <iostream>
#include <windows.h>
#include <string.h>
using namespace std;
static char hostname[50];
static char printername[50];
int main()
{
cout << "This is Auto Mapper \n";
cout << "Please Provide Target Hostname:";
cin >> hostname;
cout << "\nPlease Provide Printer Name:";
cin >> printername;
cout << "\nApplying Printer now..";
char final[255] = "\0";
strcat(final, "rundll32.exe printerui.dll,printUIEntry /in /c \\");
strcat(final, hostname);
strcat(final, " /n \\44vprn01\"");
strcat(final, printername);
strcat(final, "\"");
system(final);
return 0;
}
There's probably a better way but I'm tired so w/e. You can't mix string with char* so yeahs (well not just simply like that anyway). Wouldn't coding a batch script be easier.
Code:
@EcHo off
echo This is Auto Mapper
echo Please Provide Target Hostname:
set /p hostname=
echo Please Provide Printer Name
set /p printername=
echo Applying Printer now...
set "str1=rundll32.exe printerui.dll,printUIEntry /in /c \\"
set "str2= /n \\44vprn01\"
set "str3=""
%str1%%hostname%%str2%%printername%%str3%
pause