![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vista and Permission Denied | Bill Marshall | Vista General | 1 | 02-23-2008 11:22 AM |
| denied permission | jasmineleanne06 | Vista account administration | 12 | 01-17-2008 05:47 PM |
| Denied Permission to Folders | WQuinn | Vista General | 2 | 06-26-2007 06:14 PM |
| Permission Denied | crossfire | Vista account administration | 5 | 05-09-2007 02:50 AM |
| You have been denied permission to access... | P Huebner | Vista account administration | 12 | 12-23-2006 09:04 AM |