Note:
To perform the following procedure, you must be logged into a client
computer as a member of the local administrators group. You cannot be logged
in with the computer (or built-in) administrator account because Admin
Approval Mode does not apply to this account. (The built-in administrator
account is disabled on new installations of Windows Vista.)
So when I read this note and it states that the Admin Approval Mode does
not apply to the builtin administrator account I don't know what I'm talking
about? That note is from the link you provided.
What I'm trying to do is very simple. The following script when run using
c:\windows gets a permission denied on the system32 folder. This happens
whether I run it using run as administrator or run it form the builtin
administrator account. When run without run as administrator severl folders
get permission denied. When run as administrator only system32 gets
permission denied.
Const ForWriting = 1
Dim arrHeaders(48),fso,ts,file2
Int sz
Set fso = CreateObject("Scripting.FileSystemObject")
Sub ShowFolderSize(filespec)
On Error Resume Next
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(filespec)
n = int(f.size)
If Err.Number <> 0 Then
MsgBox Err.Number & ": " & Err.Description & filespec
Err.Clear
End If
sz = sz + n
n = FormatNumber(n,False,False,-1)
s = UCase(f.Name) & Space(30 - Len(f.Name)) & "uses " & Space(18-Len(n))
& n & " bytes."
str = str & s & vbcrlf
End Sub
Function Search(Dir)
Set objShell = CreateObject("Shell.Application")
Set objfolder = objShell.Namespace(Dir)
For Each strFileName in objFolder.Items
If fso.FolderExists(Dir & "\" & strFileName) = True Then
ShowFolderSize(Dir & "\" & strFileName)
End If
next
str = str & vbcrlf
End Function
set file2 = fso.CreateTextFile("C:\temp\filelst.txt", ForWriting, True)
str = ""
str1 = InputBox("Enter directory?")
Search(str1)
sz = FormatNumber(sz,False,False,-1)
str = str & vbcrlf & "Total bytes " & sz
wscript.Echo str
file2.write(str)
file2.close