MS VBScript runtime error: Permission denied

Dan used Ask the Experts™
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

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 (
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
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
         FilesSkipped = FilesSkipped + 1
         End If
   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
         FoldersSkipped = FoldersSkipped + 1
         End If
      ProcessFolder SubFolder
   End Sub
Function PromptYesNo (ByVal PromptText)
      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."
   End Function

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Network Engineer
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