+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
Coding Thread, FileSystemObject Folder why permission denied in Coding and Web Development; Having failed to make it work in WSH I turned my attention to .Net scripting First, PowerShell Code: PS_Prompt> $fso= ...
  1. #16

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: FileSystemObject Folder why permission denied

    Having failed to make it work in WSH I turned my attention to .Net scripting

    First, PowerShell
    Code:
    PS_Prompt> $fso= New-Object -ComObject Scripting.FilesSystemObject
    PS_Prompt> CD E:\HomeFolders\Year7
    PS_Prompt> $hmrt = $fso.GetFolder($pwd) ; $hmrt.subfolders| where-object -filterscript {$_.size -gt 40000000} |  % {write-host $_.Name,($_.size/1024/1024) -Separator ","}
    OK technically this is not a script but what I actually typed at the command line to get a list of all folders consuming more than 40MB. Because I used the $pwd variable I can just CD into the desired root folder and up arrow and re-use the same 'code'. PERL coders may recognise the use of $_ to represent the current record. The % is an alias for the ForEach-Object enumerator.

    I also tried using the .NET version of JScript
    This is more compiled rather interpreted 'scripting'

    Code:
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var f = fso.GetFolder(".\\");
    var fc = new Enumerator(f.SubFolders) ;
    for (;!fc.atEnd(); fc.moveNext())
          {
           
       	print(fc.item().path + " " + (fc.item().size/1024/1024));
             
          };
    This compiles to an EXE using jsc and will tell you the number of megabytes consumed by the subfolders in the current directory.

    Notice print() ather than wscript.echo(). This is .net not WSH so you loose alot of the properties and methods of the wscript object, which is quite annoying.

    Anyway, it is clear that there wasn't a permissions issue as the relevant FSO methods work under .NET but not WSH

    Go figure </American

  2. #17

    Join Date
    Sep 2011
    Location
    Dublin
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Check FSO current dir

    I had the same issue and I discovered that the problem was my fso.CurrentDirectory was set to the directory I was trying to delete. Hope that helps!



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Photostory Access denied error.
    By ICT_GUY in forum Windows
    Replies: 20
    Last Post: 10th February 2010, 12:03 PM
  2. adding folder security permission on all PCs
    By edie209 in forum Windows
    Replies: 7
    Last Post: 7th December 2007, 12:39 PM
  3. Folder Redirection and Permission problem
    By ArchersIT in forum Windows
    Replies: 8
    Last Post: 24th July 2007, 10:02 AM
  4. Permission set on redirected folder not applying (GPO issue)
    By projector1 in forum Wireless Networks
    Replies: 3
    Last Post: 14th February 2007, 01:46 PM
  5. Replies: 15
    Last Post: 12th October 2006, 10:37 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •