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

  1. /* Rexxprogram deletes all assigned printers of all users        */
  2. /* of the domain                            */
  3. /* file LSRXUT.DLL should be located in C:\OS2\DLL            */
  4. /* file RXUTILS.DLL should be located in C:\OS2\DLL            */
  5. /* in C:\IBMLAN\IBMLAN.ini there is a parameter called OTHDOMAIN=    */
  6. /* OTHDOMAIN must not contain anything                    */
  7. /* deletes all assigned printers of all users from the domain        */
  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.  
  14. say 'created by Stefan Beck, stefan_beck_xyz@yahoo.com'
  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. NETACCESS = 10
  27. NETALIAS = 20
  28. NETLOGONASN = 52
  29. NETGROUP = 70
  30. NETSHARE = 190
  31. NETUSER = 280
  32. NETUSERGROUPS = 330
  33. NETGROUPUSERS = 340
  34.  
  35.  
  36. log = 'd:\assigned.txt'
  37. user = 'd:\user.txt'
  38. out = 'd:\result.txt'
  39.  
  40.  
  41. rc=Sysfiledelete(out)
  42.  
  43.  
  44. rc = Sysfiledelete(user)
  45.  
  46. /* get the name of the server */
  47.  
  48.  
  49.  
  50. log1 = 'x'
  51.  
  52. 'net alias >x'
  53.  
  54. zeile1=linein(log1)
  55. zeile2=linein(log1)
  56.  
  57. srvname = subword(zeile2,3,10)
  58.  
  59. /* ENDE SERVERNAME */
  60.  
  61.  
  62. myRc = NetEnumerate(NETUSER, 'userInfo', SrvName)
  63.  
  64. if myRc <> '0' then do
  65.   say 'Got error from NetEnumerate() ' myRc
  66.   call DropLsRxutFuncs
  67.   exit 9
  68. end
  69.  
  70. if userInfo.0 = 0 then do
  71.   say 'No user accounts defined'
  72.   call DropLsRxutFuncs
  73.   exit 0
  74. end
  75.  
  76. say 'Number of users defined: ' userInfo.0
  77.  
  78. do p = 1 to userinfo.0
  79. rc = lineout(user,userinfo.p)
  80. end
  81.  
  82.  
  83. do until Userid = ENDE
  84.  
  85. Userid=Linein(log)
  86. Alias = Linein(log)
  87. AliasType = Linein(log)
  88. Localname = Linein(log)
  89. x = Linein(log)
  90.  
  91. /*
  92. say Userid
  93. say Alias
  94. say SrvName
  95. */
  96.  
  97. if Userid = ENDE then exit
  98.  
  99.  
  100.   myRc = NetDelete(NETLOGONASN, SrvName, UserId, Alias)
  101.   
  102.   if myRc <> '0' then do
  103.    say 'Got error from NetDelete() ' myRc
  104.    Fehler = myRc || '  ' || Userid
  105.    rc=Lineout(out,Fehler)
  106.   end
  107.   else do
  108.    say 'Logon Assignment removed successfully'
  109.    rc=Lineout(out,'Logon assignment removed successfully,' || Userid)
  110.  
  111.    say
  112.   end
  113.   
  114.  
  115. end  
  116.   
  117. exit 0
  118.   
  119.     
  120.