home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / chghome.cmd < prev    next >
OS/2 REXX Batch file  |  1999-03-04  |  5KB  |  154 lines

  1. /*---------------------------------------------------------------------------*\
  2. |  Change HomeDirectories properties          (C) Alain Rykaert - MAR99-MAR99 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.01'
  5.     Say '* CHGHOME Version' Version
  6.  
  7.  /*=============================*/
  8.     LogFileName = 'CHGHOME.LOG'                            /* LOG File Name*/
  9.  /*=============================*/
  10.  
  11.     Call Init                                                 /* init dll's*/
  12.  
  13.     Parse Upper Arg DCName OldServer NewServer
  14.  
  15.     If DCName = '' | OldServer = '' | NewServer = ''
  16.       Then Do
  17.              Say '*'
  18.              Say '* Change Home Directories Properties'
  19.              Say '*'
  20.              Say '* Usage: CHGHOME {DCName} {OldServer} {NewServer}'
  21.              Say '*'
  22.              Say '* Sample: CHGHOME DC01 FS01 FS03'
  23.              Say '*'
  24.              Exit
  25.            End
  26.       Else Nop
  27.  
  28.     DCName = Strip(DCName,'L','\')
  29.     NewServer = Strip(NewServer)
  30.     OldServer = Strip(OldServer)
  31.  
  32.     Say '* Server Name:' '\\'DCName
  33.  
  34.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)
  35.     If RC = 0
  36.       Then Do
  37.              ServerRole = ServerModalInfo.Role
  38.              If WordPos('Primary', ServerRole) > 0     /* check server role*/
  39.                Then Nop
  40.                Else Do
  41.                       Say '! This is not a Primary Domain Controller' '07'x
  42.                       Exit
  43.                     End
  44.            End
  45.       Else Call ChkError RC
  46.  
  47.     RC = NetEnumerate(280, 'UserID', '\\'DCName)           /* get all users*/
  48.     If RC = 0
  49.       Then Do
  50.              Call RxStemSort 'UserID'                     /* sort all users*/
  51.              Do i = 1 to UserID.0 - 2950
  52.                Counter = '('Right(i,Length(UserID.0))'/'Right(UserID.0,Length(UserID.0))')'
  53.                Call NetGetInfo 280, 'UserInfo', '\\'DCName, UserID.i
  54.                If UserInfo.Home_Dir = '-none-'
  55.                  Then Nop
  56.                  Else Do
  57.                         Say ' ' Counter Left(UserID.i, 10) '->' UserInfo.Home_Dir
  58.                         If Pos(OldServer, UserInfo.Home_Dir) > 0
  59.                           Then Do
  60.                                  If Left(UserInfo.Home_Dir,2) = '\\'
  61.                                    Then Do
  62.                                           Parse Var UserInfo.Home_Dir '\\' ServerName '\' Rest
  63.                                           NewHomeDir = '\\'NewServer'\'Rest
  64.                                         End
  65.                                    Else Do
  66.                                           Parse Var UserInfo.Home_Dir Drive '\' ServerName '\' Rest
  67.                                           NewHomeDir = Drive'\'NewServer'\'Rest
  68.                                         End
  69.                                  Say '09'x NewHomeDir
  70.                                  RC = NetSetInfo(230, '\\'DCName, UserID.i, NewHomeDir)
  71.                                  If RC = 0
  72.                                    Then Nop
  73.                                    Else Call ChkError RC
  74.                                End
  75.                           Else Nop
  76.                       End
  77.              End
  78.            End
  79.       Else Call ChkError RC
  80.  
  81.     Exit
  82.  
  83.  INIT:/* --------------------------------------------------------------------*/
  84.  
  85.    '@echo off'
  86.     BootDrive = Left(Value('ComSpec',,'OS2Environment'),2)
  87.  
  88.     If RxFuncQuery('SysLoadFuncs')
  89.       Then Do
  90.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  91.              Call SysLoadFuncs
  92.            End
  93.       Else Nop
  94.  
  95.     LSRDrive = Left(SysSearchPath('PATH', 'NET.EXE'), 2)    /* IBMLAN Drive*/
  96.     If LSRDrive <> ''
  97.       Then Nop
  98.       Else Do
  99.              Say '! Could not determine the Lan Requester path' '07'x
  100.              Exit X2D('1604')
  101.            End
  102.  
  103.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  104.     If RxFuncQuery('LoadLSRXUTFuncs')
  105.       Then Do
  106.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  107.              Call LoadLsRxutFuncs
  108.            End
  109.       Else Nop
  110.  
  111.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  112.     If RxFuncQuery('RxLoadFuncs')
  113.       Then Do
  114.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  115.              Call RxLoadFuncs
  116.            End
  117.       Else Nop
  118.  
  119.     Return
  120.  
  121.  CHKERROR:/* ----------------------------------------------------------------*/
  122.  
  123.     Parse Arg RCode
  124.  
  125.     Say '! Error:' RCode '07'x
  126.     Exit
  127.  
  128.     Return
  129.  
  130.  CHKFILE:/* -----------------------------------------------------------------*/
  131.  
  132.     Parse Arg File_To_Check
  133.  
  134.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  135.       Then Do
  136.              Say '! File not found:' File_To_Check '07'x
  137.              Exit
  138.            End
  139.       Else Nop
  140.  
  141.     Return
  142.  
  143.  LOGIT:/* ------------------------------------------------------------------*/
  144.  
  145.     Parse Arg Log_Text
  146.  
  147.     Log_Text = Date('E') Time() Log_Text
  148.  
  149.     Call LineOut LogFileName, Log_Text
  150.     Call Stream LogFileName, 'C', 'Close'
  151.  
  152.     Return
  153.  
  154.