I have the below code in ASP.NET C# and it work fine in local system + production machine when i tested in debug mode. but it doesn't work when i uploading to IIS.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = Server.MapPath(filePath);
startInfo.Verb = "print";
startInfo.Arguments = "Printer Name";
Process proc = new Process();
proc.StartInfo = startInfo;
proc.Start();
proc.WaitForExit(5000);
if (proc.HasExited == false)
{
proc.Kill();
}
Things i tried.
- Control panel > Admin Services > Services > IIS Admin Service > Log on Tab > check to interact with desktop. Reset IIS Admin and IIS.
- Printer Properties > Security > Grand ASPNET, NETWORK SERVICE, EVERYONE to full access.
- Tried to set another printer as Default Printer. Reinstall / Add Printer.
I tried all the above with no success. finally i tried below in my machine.config.
- WINNT>Microsoft.NET>Framework>v2.52something>Config> machine.config
I replaced this
processModel autoConfig="true"
with this
processModel userName="SYSTEM" password="AutoGenerate"
and i am getting this message
"Before you can perform print-related tasks you need to install a printer"
i am using acrobat 7 and i can print the test page from printer itself and from acrobat software.