2

I have been stuck in one of the task and it's taking days to get through. I have written a windows service which will take print. I have installed windows service under user on which printer is installed.

Now what i want is to print the document. I have been using this code and it is working perfectly fine in console application but when i copy past the code in windows service it does not do any thing. No exception nothing at all. Stuck at this point. Kindly help please

       var fileToPrint = @"http://www.myurl.com";
        using (Process printProcess = new Process())
        {
            string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
            printProcess.StartInfo.FileName = systemPath + @"\rundll32.exe";
            printProcess.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + fileToPrint + @"""";
            //printProcess.StartInfo.UseShellExecute = true;
            //printProcess.StartInfo.Verb = "print";
            printProcess.StartInfo.CreateNoWindow = true;
            printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            printProcess.Start();
        }

Thanks alot.

Edit -1 I have came across this answer here. I have tested it already. Works perfectly in Console application but in windows service no luck

Community
  • 1
  • 1
kool_Coder
  • 149
  • 1
  • 12

0 Answers0