Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for checkprn.rex

(view source code of checkprn.rex as plain text)

  1. /* * * * * * * * * * * * * * * * * * */
  2. /* CheckPrn                          */
  3. /* Check selected printer settings   */
  4. /* and start Add New Printer Wizard  */
  5. /* if necessary                      */
  6. /*                                   */
  7. /* Written by Rob van der Woude      */
  8. /* Version 4.02                      */
  9. /* Latest Revision: 1999/09/04       */
  10. /* * * * * * * * * * * * * * * * * * */
  11.  
  12.  
  13. /* Valid printer descriptions */
  14. valid.0 = 2
  15. valid.1 = "HP LaserJet III PostScript"
  16. valid.2 = "\\NTPS"
  17.  
  18.  
  19. /* Initialize */
  20. "@ECHO OFF"
  21. ok = 0
  22.  
  23.  
  24. /* Read client name and default printer from registry */
  25. hkey         = "HKEY_CURRENT_USER"
  26. subkeyname   = "Printers"
  27. subkeyhandle = w32RegOpenKey( hkey, subkeyname )
  28. printer      = w32RegQueryValue( subkeyhandle, "DeviceOld" )
  29. clientname   = w32ExpandEnvironmentStrings("%CLIENTNAME%")
  30. username     = w32ExpandEnvironmentStrings("%USERNAME%")
  31. call w32RegCloseKey subkeyhandle
  32.  
  33.  
  34. /* Display current settings */
  35. parse value printer with client"#"prndescr",".
  36. "CLS"
  37. say
  38. say "Clientname       : "||clientname
  39. say "Selected printer : "||client||"#"||prndescr
  40.  
  41.  
  42. /* Check if default printer is valid */
  43. if clientname <> client then call Wizard
  44. do i = 1 to valid.0
  45. 	pdlength = length( valid.i )
  46. 	if left( prndescr, pdlength ) = valid.i then ok = 1
  47. end
  48. if ok = 0 then call Wizard
  49. EXIT 0
  50.  
  51.  
  52. /* Procedure to display message and start Add Printer Wizard */
  53. Wizard:
  54. 	"CLS"
  55. 	say
  56. 	say "Clientname       : "||clientname
  57. 	say "Selected printer : "||client||"#"||prndescr
  58. 	"START /MIN /W MSG.EXE "||username||" /W You should create a new printer object"
  59. 	"START /MIN RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter"
  60. 	EXIT 1
  61. return
  62.  

page last modified: 2024-04-16; loaded in 0.0281 seconds