MS VBScript runtime error: Permission denied

Dan
Dan used Ask the Experts™
on
I'm trying to run a vbscript, but it's giving me problems.  I tested the script on a PC with windows XP, which included multiple files and folders and it worked great.

Now I'm trying to run the script on my server, but it's giving me this error message:
C:\mediafiles\lowercase.vbs(46,10) Microsoft VBScript runtime error: Permission denied

So I looked at line 46, character 10, and this is what it is:
SubFolder.Move LCase(SubFolder.Path)

The entire section is below as below as well:
For Each SubFolder In SubFolders
      If SubFolder.Name <> LCase(SubFolder.Name) Then
         SubFolder.Move LCase(SubFolder.Path)
         FoldersRenamed = FoldersRenamed + 1
        Else


I have attached the entire code below under the code section.
If anyone knows how to fix this problem, I would greatly appreciate it.

I even ran the CMD prompt as administrator.  I also gave everyone full access to that folder, and still the same problem.

Any help would be much appreciated.
' RenLowercase.vbs  -  Rename files and directories to lowercase
'
' This script renames all the files and subdirectories in the current
' directory and all it's subdirectories to lowercase.
'
' Author: Christian d'Heureuse (www.source-code.biz)
 
Option Explicit
 
Dim StdIn:  Set StdIn = WScript.StdIn
Dim StdOut: Set StdOut = WScript.StdOut
Dim fso:    Set fso = CreateObject("Scripting.FileSystemObject")
 
Dim FilesRenamed:   FilesRenamed = 0
Dim FilesSkipped:   FilesSkipped = 0
Dim FoldersRenamed: FoldersRenamed = 0
Dim FoldersSkipped: FoldersSkipped = 0
 
Main
 
Sub Main
   Dim CurrentFolder: Set CurrentFolder = fso.GetFolder(".")
   StdOut.WriteLine "Warning: All files and subdirectories within the directory """ & _
         CurrentFolder.Path & """ and all it's subdirectories will be renamed to lowercase."
   If Not PromptYesNo("Continue?") Then Exit Sub
   ProcessFolder CurrentFolder
   StdOut.WriteLine FilesRenamed & " Files and " & FoldersRenamed & " Folders renamed to lowercase."
   StdOut.WriteLine FilesSkipped & " Files and " & FoldersSkipped & " Folders were already lowercase."
   End Sub
 
Sub ProcessFolder (ByVal Folder)
   Dim Files: Set Files = Folder.Files
   Dim File
   For Each File In Files
      If File.Name <> LCase(File.Name) Then
         File.Move LCase(File.Path)
         FilesRenamed = FilesRenamed + 1
        Else
         FilesSkipped = FilesSkipped + 1
         End If
      Next
   Dim SubFolders: Set SubFolders = Folder.SubFolders
   Dim SubFolder
   For Each SubFolder In SubFolders
      If SubFolder.Name <> LCase(SubFolder.Name) Then
         SubFolder.Move LCase(SubFolder.Path)
         FoldersRenamed = FoldersRenamed + 1
        Else
         FoldersSkipped = FoldersSkipped + 1
         End If
      ProcessFolder SubFolder
      Next
   End Sub
 
Function PromptYesNo (ByVal PromptText)
   Do
      StdOut.Write PromptText & " (y/n) - "
      Dim s: s = StdIn.ReadLine()
      Select Case LCase(Trim(s))
         Case "n","no"  PromptYesNo = False: Exit Function
         Case "y","yes" PromptYesNo = True:  Exit Function
         End Select
      StdOut.WriteLine "Invalid input."
      Loop
   End Function

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Network Engineer
Commented:
The problem was that some files were in use.
I stopped the following services, and then the script worked great.
1. WWW service
2. IIS Admin service
3. Windows Media Services
4. Flash server
5. Apache Service

I ran the script and then restarted all the services again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial