Batch File Command Problem
Results 1 to 2 of 2

Thread: Batch File Command Problem

  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Batch File Command Problem

    I am trying to develop a batch file which deletes user profiles. In our profile directory there are four user profile folders which must
    not be deleted but all the rest must be deleted. I am trying to create a batch file that copies the four folders to a new directory and then deletes the rest of the folders in the original directory. So I am wondering in Windows NT and 2000 is there a command that actually deletes folders and subfolders? And is there a command that Copies actual folders from one destination to another? If not is there a command that copies files from subfolders within folders.

    Thank you very much for any help,

    Matthew

  2. #2
    Join Date
    Oct 2001
    Location
    Belleville, Ontario, Canada
    Posts
    98
    I don't have a Windows NT system availabel to get details on the required syntax, but I think something like this could work:

    ----Batch File Begin----
    @ECHO OFF
    TITLE SLiC Profile Cleanup
    COLOR 17

    IF EXIST %WINDIR%\Profiles\User1\FlagFile.ext XCOPY %WINDIR%\Profiles\User1\*.* %WINDIR%\SLiC\Profiles\User1\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\Profiles\User2\FlagFile.ext XCOPY %WINDIR%\Profiles\User2\*.* %WINDIR%\SLiC\Profiles\User2\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\Profiles\User3\FlagFile.ext XCOPY %WINDIR%\Profiles\User3\*.* %WINDIR%\SLiC\Profiles\User3\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\Profiles\User4\FlagFile.ext XCOPY %WINDIR%\Profiles\User4\*.* %WINDIR%\SLiC\Profiles\User4\*.* /V /C /I /Q /H /R > NUL

    DELTREE %WINDIR%\Profiles /Y

    MKDIR %WINDIR%\Profiles

    IF EXIST %WINDIR%\SLiC\Profiles\User1\FlagFile.ext XCOPY %WINDIR%\SLiC\Profiles\User1\*.* %WINDIR%\Profiles\User1\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\SLiC\Profiles\User2\FlagFile.ext XCOPY %WINDIR%\SLiC\Profiles\User2\*.* %WINDIR%\Profiles\User2\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\SLiC\Profiles\User3\FlagFile.ext XCOPY %WINDIR%\SLiC\Profiles\User3\*.* %WINDIR%\Profiles\User3\*.* /V /C /I /Q /H /R > NUL
    IF EXIST %WINDIR%\SLiC\Profiles\User4\FlagFile.ext XCOPY %WINDIR%\SLiC\Profiles\User4\*.* %WINDIR%\Profiles\User4\*.* /V /C /I /Q /H /R > NUL

    REM Written By SLiC
    REM Last revised October 26, 2003
    -----Batch File End-----

    Becareful ... do not assume this is OK as is!!
    First .... test on what is safe.
    FlagFile.ext referrs to a flag file to use as a check (i.e. KeepMe.TXT)
    User# referrs to the profile to be kept.
    This batch will fail if run while a user is logged on, as that users profile would be in use. Therefore it would be best to schedule it to run during a time when the users are logged off.

    Double check and test, test, test ... before using even once.

    Hope this helps
    Excellence is the result of caring more than others think is wise; risking more than others think is safe; daring more than others think is practical; and expecting more than others think is possible.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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