+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Remove Folders Using CMD in Coding and Web Development; So Bossman gave me the solution to a problem we're having with Symantec, and rather than run the solution manually ...
  1. #1

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242

    Remove Folders Using CMD

    So Bossman gave me the solution to a problem we're having with Symantec, and rather than run the solution manually on the machines as and when they suffer the problem (as it takes about 10 minutes) I thought I'd put it in a batch file to do it for me.

    It's about done, but I need two things adding to my batch file:

    1) Delete all folders (and files within them) from C:\Program Files\Common Files\Symantec Shared\VirusDefs where the folder name matches ????????.??? (where ? is a single wild card character)

    2) Delete all folders (and files within them) from C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\I2_LDVP.VDB

    The trouble I'm having is that you cannot use wild card characters in a batch file command such as RMDIR or RD. I think the way to do this would be with a loop, but I'm not sure where to start so any help would be appreciated.

    Thanks,

  2. #2

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    66
    Quote Originally Posted by Hightower View Post
    So Bossman gave me the solution to a problem we're having with Symantec, and rather than run the solution manually on the machines as and when they suffer the problem (as it takes about 10 minutes) I thought I'd put it in a batch file to do it for me.

    It's about done, but I need two things adding to my batch file:

    1) Delete all folders (and files within them) from C:\Program Files\Common Files\Symantec Shared\VirusDefs where the folder name matches ????????.??? (where ? is a single wild card character)

    2) Delete all folders (and files within them) from C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\I2_LDVP.VDB

    The trouble I'm having is that you cannot use wild card characters in a batch file command such as RMDIR or RD. I think the way to do this would be with a loop, but I'm not sure where to start so any help would be appreciated.

    Thanks,
    Don't have SAV but this looks relatively simple - just to clarify

    (1), is there always only a single folder under VirusDefs that you wish to remove and no other files in the root VirusDefs folder, or are there multiple files in there and you want to specify a specific filename when running the batch to remove only one file?

    (2) Is I2_LDVP.VDB the folder name? If you want everything gone from under it, can you do it the lazy way and just
    Code:
    rd /s /q I2_LDVP.VDB (Remove I2_LDVP.VDB and all subfolders, no prompting)
    md I2_LDVP.VDB (Recreate I2_LDVP.VDB)
    or is this locked while SAV is running? If you need to do it in a loop, it should be

    Code:
    del /q "C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\I2_LDVP.VDB\*"
    for /D %%I in (C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\I2_LDVP.VDB\*) do RD /s /q "C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\I2_LDVP.VDB\%%I"

  3. Thanks to OutToLunch from:

    Hightower (18th September 2009)

  4. #3

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242
    Thanks - that loop should get me going

  5. #4

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242
    Need to use a wild card character in an if statement like:

    Code:
    if %%I == "????????.???" ECHO This works!
    So it is any 8 characters followed by a dot followed by any 3 characters.

    Anybody got any ideas how to do this because the above doesn't work.

  6. #5


    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,317
    Thank Post
    131
    Thanked 355 Times in 293 Posts
    Blog Entries
    4
    Rep Power
    142
    Quote Originally Posted by Hightower View Post
    Need to use a wild card character in an if statement like:

    Code:
    if %%I == "????????.???" ECHO This works!
    So it is any 8 characters followed by a dot followed by any 3 characters.

    Anybody got any ideas how to do this because the above doesn't work.
    Use PowerShell?

    Lets you do it with regular expressions, which might make things much easier for you.

  7. #6

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    66
    findstr in a normal batch will let you use regex, should be able to get this to combine and do what you want but haven't got any time left this afternoon to play - findstr /? on the console will give you some ideas of what you can do with it.



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 0
    Last Post: 29th August 2009, 01:39 PM
  2. remove apps via cmd, winadmin irc?
    By danboid in forum Windows
    Replies: 9
    Last Post: 19th October 2008, 09:29 PM
  3. Trying to remove Favorite Links and Folders from MY TS server
    By k-strider in forum Windows Server 2008
    Replies: 0
    Last Post: 13th May 2008, 01:14 PM
  4. Replies: 0
    Last Post: 20th August 2007, 03:20 PM
  5. Replies: 7
    Last Post: 2nd November 2006, 02:42 PM

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
  •