home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / servprin.zip / getprint.cmd < prev    next >
OS/2 REXX Batch file  |  2001-02-17  |  2KB  |  117 lines

  1. /* Rexxprogram reads all assigned printers off all users        */
  2. /* file LSRXUT.DLL should be located in C:\OS2\DLL            */
  3. /* file RXUTILS.DLL should be located in C:\OS2\DLL            */
  4. /* in C:\IBMLAN\IBMLAN.ini there is a parameter called OTHDOMAIN=    */
  5. /* OTHDOMAIN must not contain anything                    */
  6. /* gets all assigned printers of all users and writes it to the        */
  7. /* file "log"                                */
  8.  
  9. /* all files are written and read from drive D:\ by default        */
  10. /* the administrator must be logged on at the server            */
  11.  
  12.  
  13. say 'created by Stefan Beck, stefan_beck_xyz@yahoo.com'
  14.  
  15.  
  16. call RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs'
  17. call SysLoadFuncs
  18.  
  19. call RxFuncAdd 'RxLoadFuncs','RXUTILS','RxLoadFuncs'
  20. call RxLoadFuncs
  21.  
  22. call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  23. call LoadLsRxutFuncs
  24.  
  25.  
  26.  
  27. NETACCESS = 10
  28. NETALIAS = 20
  29. NETLOGONASN = 52
  30. NETGROUP = 70
  31. NETSHARE = 190
  32. NETUSER = 280
  33. NETUSERGROUPS = 330
  34. NETGROUPUSERS = 340
  35.  
  36. log = 'd:\zuord.txt'
  37.  
  38. rc=SysFileDelete(log)
  39.  
  40.  
  41.  
  42. /* get the name of the server */
  43.  
  44. log1 = 'x'
  45.  
  46. 'net alias >x'
  47.  
  48. zeile1=linein(log1)
  49. zeile2=linein(log1)
  50.  
  51. srvname = subword(zeile2,3,10)
  52.  
  53. /* ENDE SERVERNAME */
  54.  
  55.  
  56. myRc = NetEnumerate(NETUSER, 'userInfo', SrvName)
  57.  
  58. if myRc <> '0' then do
  59.   say 'Got error from NetEnumerate() ' myRc
  60.   call DropLsRxutFuncs
  61.   exit 9
  62. end
  63.  
  64. if userInfo.0 = 0 then do
  65.   say 'No user accounts defined'
  66.   call DropLsRxutFuncs
  67.   exit 0
  68. end
  69.  
  70. say 'Number of users defined: ' userInfo.0
  71.  
  72. do p = 1 to userinfo.0
  73. rc = lineout('d:\user.txt',userinfo.p)
  74. end
  75.  
  76.  
  77. do p = 1 to userinfo.0
  78.  
  79.  myRc = NetGetInfo(NETLOGONASN, 'logonAsnInfo', SrvName, userinfo.p)
  80.   
  81.   if myRc <> '0' then do
  82.    say 'Got error from NetGetInfo() ' myRc
  83.    call DropLsRxutFuncs
  84.    exit 9
  85.   end
  86.   
  87.   if logonAsnInfo.count = 0 then do
  88.    say 'No logon assignments'
  89.    call DropLsRxutFuncs
  90.    exit 0
  91.   end
  92.  
  93.  
  94. do i=1 to logonAsnInfo.count
  95.  
  96. if logonAsnInfo.i.type = 'Printer alias' then
  97. do
  98. rc = lineout(log,userinfo.p)
  99.  
  100. rc = lineout(log,logonAsnInfo.i.alias)
  101. rc = lineout(log,logonAsnInfo.i.type)
  102. rc = lineout(log,logonAsnInfo.i.device)
  103.  
  104. rc = lineout(log,' ')
  105. end
  106.  
  107. end
  108.  
  109. end  
  110.  
  111.  
  112. rc = lineout(log,'ENDE')
  113.  
  114. exit 0
  115.   
  116.     
  117.