Hi there! I've searched around the archives (and Google, etc) to find the answer to this but can't quite find what I'm after.
We need to find a users default printer and then map it to LPT1 for some legacy DOS applications.
"This answer has been posted loads of times!" I hear you cry! Yep, I've seen several very good posts on this but our particular problem is that we have a Group Policy in Active Directory which disables registry editing for all users. Therefore on our old NT machines in our Resource domain the old (existing) code which looks like this:
Code:
;$prn = READVALUE( "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device" )
;$pos = INSTR( $prn, "," ) ; Look for the first comma
;IF $pos <> 0 ; If a comma was found then strip them out
; $prn = SUBSTR( $prn, 1, $pos-1 )
;ENDIF
;$pos = INSTR( $prn, "\" ) ; Look for the first \\
;IF $prn <> "" AND $pos <>0
; USE LPT1: $prn ; Map LPT1: to the default printer
; COLOR c+/n
; AT(20,22) $prn + " > lpt1:"
;ELSE
; COLOR r+/n
; AT(20,22) 'No printer installed'
;ENDIF
Works nicely, but when we move new XP machines into the AD domain and apply group policy, the logon script stops at that point with a dialog box stating (not surprisingly) "Registry Editing has been disabled by your administrator" [OK].
I know that there are ways around it like creating security groups (ie per department) and using INGROUP as a condition to map what printer to LPT1 but that's a lot of work and adds to group maintenance.
Does anyone have any ideas on how we can determine which printer is set to default and map it to LPT1 without it checking thru the registry?
I have a feeling this may be really easy for someone OR really difficult/impossible! Either way your help is appreciated and I've learnt a lot from reading thru the various posts on this board (thanks!).
Regards,
Andrew.