Help with CMD - ATTRIB and outputting results

April 9, 2011 at 01:48:12
Specs: Windows 7
How do I output the results from command line's ATTRIB command to a text file? I'm trying to use VB6 and Batch files together, by choosing the path from a Dir box in VB6, then VB6 writes a batch file to do an Attrib. I'd like to output those results to a text file and read it back in to VB6, any idea how I could do this? (Just the output part, I'm fine with the rest.)

See More: Help with CMD - ATTRIB and outputting results

Report •

#1
April 9, 2011 at 02:09:09
Better idea: Just get the information in VB6. For VBScript, I'd use Scripting.FileSystemObject's File.Attributes. VB6 might even have some way of enumerating file attributes without COM objects.

How To Ask Questions The Smart Way


Report •

#2
April 9, 2011 at 02:20:10
As far as I'm currently aware, it won't quite do the same thing. ATTRIB shows a list of hidden system files within a directory, along with it's WINDOWS permissions. I hope to advance to the stage where I can type permissions to remove from a file found in the ATTRIB (-s -h -r) within VB6 too, but I'm pretty sure I can't do it within VB6.

Is there any way to write the output to a Text file or am I dreaming a little bit too much? :D


Report •

#3
April 9, 2011 at 02:50:58

attrib /s /d *.* > file


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
April 9, 2011 at 03:09:00
Thanks Mechanix, that worked an absolute TREEEEEAT, LOVE YOU!

Report •

#5
April 9, 2011 at 03:39:02
What do you mean by "WINDOWS permissions?" You mean the ACLs? I'm pretty sure ATTRIB doesn't enumerate the ACLs. If you mean file permissions, then I'm pretty sure at least FileSystemObject can do it:
Set fso = CreateObject("Scripting.FileSystemObject")
For Each file In fso.GetFolder("C:\").Files
  WScript.Echo showAttrib(file) & " - " & file
Next 'file

Function showAttrib(oFile)
  attrib = Array("R", "H", "S", "V", "D", "A", "L", "C")
  rawAttrib = oFile.Attributes 
  For i = 0 To 5
    If Not rawAttrib And (2 ^ i) Then _
      attrib(i) = " "
  Next 'i
  If Not rawAttrib And 1024 Then _
    attrib(6) = " "
  If Not rawAttrib And 2048 Then _
    attrib(7) = " "
  showAttrib = Join(attrib, "")
End Function

How To Ask Questions The Smart Way


Report •

#6
April 9, 2011 at 04:20:24
R2 goes where angels fear to tread.

I noticed that 'permissions' but decided to play dumb.


=====================================
Life is too important to be taken seriously.

M2


Report •

#7
April 9, 2011 at 04:31:06
Only because I realize it's a moot point now that gum.Pseud got what he wanted.

Sometimes I just want to reach out and shake someone, telling them there are better ways.

How To Ask Questions The Smart Way


Report •

Ask Question