Solved

script to run attrib command

Posted on 2006-06-14
5
511 Views
Last Modified: 2013-12-03
Hello,
I am looking for a script that will enumerate a certain set of folders
then run the attrib command to clear the Archive bit

The directory structure is like this:
Y:\files\a\a\aauser\profile
Y:\files\z\z\zzuser\profile

I was hoping to run the command on the 'profile' folder and all its contents
If it matters, the profile folder is always the same level deep in the directory structure

Thank you for any help you can give me
0
Comment
Question by:mdiglio
  • 2
  • 2
5 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 50 total points
ID: 16908654
The easiest way would probably be to

-------------->8-----------------
@echo off
attrib -A Y:\files\*.* /s
-------------->8-----------------

Are there any other constraints?
0
 
LVL 16

Author Comment

by:mdiglio
ID: 16908902
Yes, sorry I wasn't clear on the environment.
The profile folder is just one folder in the user's home directory
I need to leave other folders/files alone

I only want to reset the archive bit on the profile folders
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 450 total points
ID: 16909901

Hi,

This quick little VbScript will look for a folder called Profile and change the archive bit to off for that folder and everything beneath it. Is that what you're looking for?

Chris


Const ARCHIVE_BIT = 32
Const STARTING_FOLDER = "Y:\"

Dim objFileSystem, objFolder

Sub FindProfile(objFolder)
      Dim objSubFolder

      For Each objSubFolder in objFolder.SubFolders
            If LCase(objSubFolder.Name) = "profile" Then
                  SetArchiveBit objSubFolder
            Else
                  FindProfile objSubFolder
            End If
      Next
End Sub

Sub SetArchiveBit(objFolder)
      Dim objFile, objSubFolder

      If objFolder.Attributes And ARCHIVE_BIT Then
            objFolder.Attributes = objFolder.Attributes - ARCHIVE_BIT
      End If

      For Each objFile in objFolder.Files
            If objFile.Attributes and ARCHIVE_BIT Then
                  objFile.Attributes = objFile.Attributes - ARCHIVE_BIT
            End If
      Next
      For Each objSubFolder in objFolder.SubFolders
            If objSubFolder.Attributes And ARCHIVE_BIT Then
                  objSubFolder.Attributes = objSubFolder.Attributes - ARCHIVE_BIT
            End If
            SetArchiveBit objSubFolder
      Next
End Sub


Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSystem.GetFolder(STARTING_FOLDER)

FindProfile objFolder
0
 
LVL 16

Author Comment

by:mdiglio
ID: 16911110
Thank You; that is exactly what I wanted to do
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 16911418

Pleasure, glad I could help.

Chris
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now