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

  1. /* Rexxprogram to get the printers asigned to each user            */
  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. /* this rexx script recreates the assigned printers from the file "log" */
  7. /* given in the script. Errors happen due to wrong names of printer    */
  8. /* aliases (2783) or wrong (2221)or non-existing user            */
  9. /* results are written to the file "out"                */
  10.  
  11. /* all files are written and read from drive D:\ by default        */
  12. /* the administrator must be logged on at the server            */
  13.  
  14.  
  15. say 'created by Stefan Beck, stefan_beck_xyz@yahoo.com'
  16.  
  17. call RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs'
  18. call SysLoadFuncs
  19.  
  20. call RxFuncAdd 'RxLoadFuncs','RXUTILS','RxLoadFuncs'
  21. call RxLoadFuncs
  22.  
  23. call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  24. call LoadLsRxutFuncs
  25.  
  26.  
  27. SAY 'Attention, this script assignes printers to all users'
  28. say 'on the current domain'
  29.  
  30. Say 'Continue (Y) ? '
  31. Pull WERT
  32.  
  33.  
  34. If WERT = Y then 
  35. do
  36.  
  37.  
  38.  
  39. NETACCESS = 10
  40. NETALIAS = 20
  41. NETLOGONASN = 52
  42. NETGROUP = 70
  43. NETSHARE = 190
  44. NETUSER = 280
  45. NETUSERGROUPS = 330
  46. NETGROUPUSERS = 340
  47.  
  48. log = 'd:\assigned.txt'
  49. out = 'd:\result.txt'
  50.  
  51. rc=Sysfiledelete(out)
  52.  
  53. /* get the name of the server */
  54.  
  55. log1 = 'x'
  56.  
  57. 'net alias >x'
  58.  
  59. zeile1=linein(log1)
  60. zeile2=linein(log1)
  61.  
  62. srvname = subword(zeile2,3,10)
  63.  
  64. rc=Sysfiledelete(log1)
  65.  
  66. /* END SERVERNAME */
  67.  
  68. /* Read file with assigned printers*/
  69.  
  70.  
  71.  
  72. do until Userid = ENDE
  73.  
  74. Userid=Linein(log)
  75. Aliasname = Linein(log)
  76. AliasType = Linein(log)
  77. Localname = Linein(log)
  78. x = Linein(log)
  79.  
  80. /*
  81. say Userid
  82. say Aliasname
  83. say Aliastype
  84. say Localname
  85. */
  86.  
  87.  
  88.  
  89.  
  90. if Userid = ENDE then exit
  91.  
  92.  MyRc = NetAdd(NETLOGONASN, srvname, aliasName, LocalName, UserId)
  93.  
  94.   if myRc <> '0' then do
  95.    say 'Got error from NetAdd() ' myRc
  96.    Fehler = myRc || '  ' || Userid
  97.    rc=Lineout(out,Fehler)
  98.    call DropLsRxutFuncs
  99.    exit 9
  100.   end
  101.   else do
  102.  
  103. /* print results to file "out"  */
  104.  
  105.    rc=Lineout(out,'Logon assignment added successfully,' || Userid)
  106.   end
  107.  
  108.   
  109. end 
  110.  
  111.  
  112. end
  113.   
  114.  
  115.  
  116.   
  117.