Results 1 to 6 of 6

Thread: Move users

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    5

    Move users

    Hi just having a little play with batch files a home.

    does anybody know if this would work , and write an error log at the same time.

    I know its a bit long, is there any way to shorten it.

    @echo off
    rem 1 username i
    rem 2 displayname j
    rem 3 ?
    rem 4 discription k
    rem 5 old home drive l
    rem 6 home path m
    rem 7 profile n
    rem 8 logon script o


    if "%1" == "" goto help
    if "%1" == "-?" goto help
    if "%1" == "/?" goto help


    echo Errorlog of movem2 created: > error.log
    date /T >> error.log
    time /T >> error.log
    echo if there is nothing below here everything went OK >> error.log


    cls
    echo Reading In .csv %1 file
    echo --------------------------------------------------------------------

    for /F "skip=1 delims=, tokens=1,2,3,4,5,6,7,8" %%i IN (%1) do (

    echo user: %%i

    echo -
    echo setting owner of \\fileserver\users\%%i and subdirectories to Administrator
    subinacl /subdirectories \\fileserver\users\%%i\* /setowner=administrator
    if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo giving rights to Domain\administartor on \\fileserver\users\%%i
    xcacls \\fileserver\users\%%i /T /E /G DOMAIN\administrator:F;F /y
    if ERRORLEVEL 1 (echo setting admin permissions on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo moving \%%i to \\SERVER\users\%%i
    xcopy s:\%%i e:\users\%%i /E /C /I /H /A /O
    if ERRORLEVEL 1 (echo xcopy on %%i did not work %ERRORLEVEL%>> error.log)

    echo -
    echo setting owner of \\SERVER\users\%%i and subdirectories to %%i
    subinacl /subdirectories \\SERVER\users\%%i\* /setowner=%%i
    if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
    xcacls e:\users\%%i /T /E /G DOMAIN\administrator:F;F /y
    if ERRORLEVEL 1 (echo setting admin permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
    xcacls e:\users\%%i /T /E /G DOMAIN\staff:R;R /y
    if ERRORLEVEL 1 (echo setting staff permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo setting DOMAIN permissions on \\SERVER\users\%%i
    xcacls e:\users\%%i /T /E /G %%i:C;C /y
    if ERRORLEVEL 1 (echo setting DOMAIN permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)

    echo -
    echo changing profile of %%i
    cusrmgr -u %%i -U %%n -h \\SERVER\users\%%i -n %%o +s CanNotChangePassword
    if ERRORLEVEL 1 (echo changing of profile on %%i did not work: %ERRORLEVEL% >> error.log)


    echo ""
    echo ----------------------------------
    echo ""


    )

    echo ""
    echo Synchronising DCs
    echo --------------------------------------------------------------------
    nltest /server:SERVER /pdc_repl

    echo Finished, press any key to look at the error log
    pause
    type error.log

    goto exit

    :help
    cls
    echo --------------------------------------------------------------------
    echo Script to Move Users and change their directories file permissions
    echo Usage:
    echo movem [filename] - where filename is a csv.
    echo e.g. movem DOMAINusers.csv
    echo --------------------------------------------------------------------

    :exit


    Cheers for looking.



  2. #2
    Succeded in braking Windo TZ Veteran Dehcbad25's Avatar
    Join Date
    Apr 2002
    Location
    DE - USA
    Posts
    2,406
    I don't really want to test it at work, and I don't have much network at home, but I think it looks interesting
    Exactly what is that you are trying to acomplish with this batch file?
    I know it says to move users and file permisions, but could you give us a practical example???
    Thanks

  3. #3
    Super Moderator Super Moderator Big Booger's Avatar
    Join Date
    Apr 2002
    Location
    JAPAN
    Posts
    10,941
    atlas you are venturing into an area into which I haven't a clue. I will be watching this thread for a more informed source to give their opinion on the batch code for which you have written. Could be interesting.


    Welcome to TZ.

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Posts
    5
    Just trying to move users from an nt server to a new 2000 server.

    But the home dirs were set with full control(before me) so the little bliters changed file perms and denied admins everything.
    also needed to change profile path.

    i think it works, but wasnt sure about the error log though.

    cheers

  5. #5
    Super Moderator Super Moderator Big Booger's Avatar
    Join Date
    Apr 2002
    Location
    JAPAN
    Posts
    10,941
    The following site might help in regards to creating an error log in a batch file.

    http://www.computerhope.com/batch.htm

    then again, it may not.

  6. #6
    Succeded in braking Windo TZ Veteran Dehcbad25's Avatar
    Join Date
    Apr 2002
    Location
    DE - USA
    Posts
    2,406
    Alright, now I understand.
    That is a very Interesting batch. Actually I am VERY interested in it, since I am planning to upgrade the servers to Windows 2K server, from the awfull NT server. I had already given up in anything automated , though all users in my Domain have different permisions.
    Sorry I can test it now, but I would glady hear from the results

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •