I have program that sends a file to a printer using 'lpr' command. I have installed Windows SDK 7.1. It is working fine in a 32 bit Windows 7 system but not working in 64 bit Windows 7.
Process proc = new Process();
proc.StartInfo.FileName = "lpr";
proc.StartInfo.WorkingDirectory = GlobalConstants.outBaseDir;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.Arguments = " -S " + GlobalConstants.printerIP + " -P RAW " + filePath;
proc.Start();
It throws an execption.
To print a file with a specific printer, execute the lp command with the '-d' option or lpr command with the '-P' option. Consider the following commands: lp -d <printer name> <file name> lpr -P <printer name> <file name>
In the case of the LPR. EXE, the command was located in %WINDIR%\system32 which means that running a command prompt from the Start menu would cause the 64-bit version of CMD. EXE to run and since this is a 64-bit process it can access the %WINDIR%\system32 directory so the LPR.
I finally got the answer to my question.
Step1: I had to enable "LPR Port Monitor". This can be done through "Control Panel/Programs and Features/Turn Windows features on or off". In the dialog expand "Print and Document Services." Check "LPR Port Monitor."
Step2: When you install Windows SDK 7.1. It will copy lpr.exe and related files into "C:\Windows\winsxs\amd64_microsoft-windows-p..ting-lprportmonitor_xxxx...". Copy the files lpr.exe, lprhelp.dll, and lprmonui.dll into the C:\Windows\sysWOW64 folder.
Thats it!!!
Reference: http://www.tomshardware.com/forum/240019-44-error-windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With