gshaw Posted June 10, 2009 Posted June 10, 2009 Bit of a strange problem really, we've got this app that's old school 16-bit style that can't find any printers when they're shared network ones but if I manually add a direct TCP\IP port type local printer it goes through fine. Is there any way to somehow redirect this to the UNC shared printers via the print server without having to map every printer via direct TCP\IP?
SYNACK Posted June 10, 2009 Posted June 10, 2009 There is a dirty way to do this for old 16bit apps. We had one that would only talk to a local printer so we had to do this for it to run. The idea is to set up a local printer on the box using the same driver as the network printer but pointed to Lpt2. You must make sure that LPT1 or 2 etc is not used in device manager and if so disable it. Then you set your network printer to map to the lpt port and when a document is printed to the local printer it is redirected to the network printer transparently. How to print to a network printer from an MS-DOS-based program in Windows XP How to redirect LPT port to IP printer 1
gshaw Posted June 10, 2009 Author Posted June 10, 2009 Sounds like extra printers will have to be mapped for that program then... bit of a pain really... time for some nifty scripting to ask which printer to map as I'm not adding 20 extra printers every time the program runs
Michael Posted June 10, 2009 Posted June 10, 2009 I had this problem recently with two applications: Eyeprofile v3 and Progress. They just won't print to any network printer. I've tried Synack's method in the past, but still no joy. The only method which works was to create a local port \\SERVER\PRINTSHARENAME install the drivers as normal and it works absolutely fine now.
gshaw Posted June 15, 2009 Author Posted June 15, 2009 Aargh this is getting so frustrating now! It only works on either a local port mapped printer or the net use LPT1 direction with a manually added printer pointing to LPT1 Found a nifty script to do it for me... Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run ("cscript c:\windows\system32\prnport.vbs -a -o raw -r IP_192.168.x.x -h 192.168.x.x") WshShell.Run ("cscript c:\windows\system32\prnmngr.vbs -a -p " & chr(34) & _ "StudyScan Printer" & chr(34) & " -m " & chr(34) & _ "hp LaserJet 4" & chr(34) & " -r " & chr(34) & "IP_192.168.x.x") But it needs to run as admin! Found autoit that encrypts the runas command into an EXE but from Google search it can't call VBS files properly Need to do this via some kinda logon script as it's on a site license so manual mapping isn't an option. Tbh it's a real kludge to get printing to work but app is so old I can't see any other way
SYNACK Posted June 15, 2009 Posted June 15, 2009 Bang, try this one. It should if run as a machine script on startup via GP it should have the nessisary privilages and will create a local IP printer port and a local printer mapping. Could be a little work to get the drivers etc right for your printer but a whole lot less work than going to every station. Script for installing local printers with TCP/IP port - Petri.co.il forums by Daniel Petri You could also try a scripted restore of the printer from a backup as at the end of this: Command Line Printer Control Use some other method to set up the ip port then use this command from MS: How to add printers with no user interaction in Windows Or implement it in a nullsoft installer: Install network printers on Windows XP - NSIS 1
gshaw Posted June 15, 2009 Author Posted June 15, 2009 Just what I was hoping for... one last search result that hadn't yet popped up while Googling Will give the Petri script a whirl and see if it does the trick... because the software is so old it actually prefers to use a Laserjet 4 driver so shouldn't be a problem there
gshaw Posted June 16, 2009 Author Posted June 16, 2009 Script works lovely but only as a local admin user... seems printer scripts can't be run at startup Back to the drawing board... is there anything like autoit that could wrap the vbs script up into an EXE with the run as credentials hidden?
User3204 Posted June 16, 2009 Posted June 16, 2009 If you make the users into Power users does this allow them to install printers this way ? It gives extra access to stuff, but less than the local admin, I know staff are able to install printers onto our staff network machines, and they have power user access (because of SIMS). There is probably a better way to allow access for this...
SYNACK Posted June 16, 2009 Posted June 16, 2009 Autoit does not play nice with VBS but you could try something like this: VBForums - View Single Post - [RESOLVED] Run script as administrator You can convert your vbscript script into EXE using this online converter http://www.vbs2exe.com Then try that under the machine logon or use autoit to repackage the exe as admin.
gshaw Posted July 8, 2009 Author Posted July 8, 2009 That converter worked but no way to purchase it here (PO only) so was back to the drawing board. Was getting very frustrating but then as if by magic the lightbulb switched on and solution found Using printui.dll in a batch file called from autoit with admin credentials... reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\The Printer Name" if %errorlevel% GTR 0 goto notinstalled exit :notinstalled rundll32 printui.dll,PrintUIEntry /if /b "The Printer Name" /f %windir%\inf\ntprint.inf /r "IP_10.0.0.1" /m "HP LaserJet 4" Then to call if from autoit... $username = "user" $password = "pass" $domain = "domain" RunAs($username, $domain, $password, 0, @ScriptDir & "\addprinter.bat", "", @SW_HIDE) Compile to EXE to hide the credentials and it works perfectly! The batch file checks if the printer already exists and doesn't map a 2nd time so looking like the perfect solution... happy days!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now