![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | permission denied problem I'm new to vista and vbscript. But I created the following script to display the size of folders in a directory. When I run the program from a cmd window that has been started with run as administrator it get permission denied on the c:\windows\system32 directory when I enter c:\windows. If I enter c: the users and windows directories get permission denied. I also get the same problem if I login as administrator. What am I doing wrong? I used the following vbscript: 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 |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Permission Denied to an Administrator | Vista account administration | |||
| Script Problem - Permission denied error | VB Script | |||
| Permission denied... | General Discussion | |||
| denied permission | Vista account administration | |||
| Permission Denied | Vista account administration | |||