Printing a file on default printer using shellexec from webservice

Hello Experts
Trying to print a document on default printer on out webserver.
This is done from a webservice.
When running it from vs2005 this works fine, but when deploying it to the webservice it fails.
Lets say its a pdf document, the acrobat process starts and the shellexecute returns with 42, but the document never prints.

Any idees??

this is the code for printing
        private string PrintFile(string fileName)
            IntPtr _intPtr = new IntPtr();
            string lpOperation = "print";
            string lpFile = fileName;
            string lpDirectory = @"\";
            ShellExecuteWrapper.ShowCmd nShowCmd = ShellExecuteWrapper.ShowCmd.SW_HIDE;
            ShellExecuteWrapper _shellExecuteWrapper = new ShellExecuteWrapper();
            _shellExecuteWrapper.hwnd = _intPtr;
            _shellExecuteWrapper.lpDirectory = lpDirectory;
            _shellExecuteWrapper.lpFile = fileName;
            _shellExecuteWrapper.lpOperation = lpOperation;
            _shellExecuteWrapper.nShowCmd = nShowCmd;

            return _shellExecuteWrapper.Result.ToString();

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

ShazbotOKConnect With a Mentor Commented:
most likely the webservice NT Authority account does not have  a "Default Printer" setup in it's profile...

You may need to use "Impersonation" for that service and use an authenticated user on the network to gain access to the printer resource.  Also no errors/messages in the event log?
tomsj188Author Commented:
Thanx for the quick response, it worked great.
All Courses

From novice to tech pro — start learning today.