Unable to run VB script
Hi I am facing error (Persmission denied 800A0046 Microsoft VBscript runtime error) while running a script on windows 2003 server. The same script runs fine on another server. Please help.
December 18th, 2009 1:34pm

If the error message includes a line number, this will indicate the statement that raised the error. It will help a lot to know what this statement is. Can you post the statement?The cause depends on what the script was attempting to do, but it could be a firewall blocking, corruption on the computer being accessed, or lack of permissions. Is the script attempting to access a resource on the local computer? Or is it attempting to access a resource remotely on another computer. Who is running the script? If the resource is remote, is the local computer joined to a domain? Finally, why run the script on a server? Can it be run from a client? Richard MuellerMVP ADSI
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2009 9:36pm

Thanks Richard for replying to my query. Below is the script whcih I am using to run on FTP server. It is used for deleting files on FTP server which are older than say 15 days. It is well running on my another FTP server. But giving error on one particular system.'Set According to the no. of days you want the data to be deleted!dtmDate = Date - 32 FolderCount = 0DeletedCount = 0 Set objFSO = CreateObject("Scripting.FileSystemObject")Set objWSH = CreateObject("WScript.Shell") 'Path where the files to be deleted are placed.strPath = "E:\home" Set Thefolder = objFSO.GetFolder(strPath) StartTime = Now WorkWithSubFolders Thefolder EndTime = NowobjWSH.Popup "Deleted: " &DeletedCount& " File(s) from "&FolderCount& " Directory(s)!!"_ &VbCrLf&VbCrLf&"Script Started: "&vbTab&StartTime&_ VbCrLf&"Script Ended: "&vbTab&EndTime,,"Deleted Files",vbInformation Sub WorkWithSubFolders (AFolder)Dim MoreFolders, TempFolder FolderCount = FolderCount + 1 CheckExt AFolder Set Morefolders = AFolder.Subfolders For Each TempFolder In MoreFolders WorkWithSubFolders (TempFolder) Next End Sub Sub CheckExt (AFolder) Dim Afile, TheFiles On Error Resume Next Set TheFiles = AFolder.Files For Each Afile In TheFiles Killfile (Afile) Next If (DeletedCount > 0) And (DeletedCount Mod 10 = 0) Then Message = "Have worked so far with " & FolderCount & " folders." &VbCrLf&VbCrLf Message = Message & "And have deleted " & DeletedCount & " files." objWSH.Popup Message, 1,"File Deletion at Work!" End If End Sub Sub Killfile (AFile) On Error Resume Next strModifyDay = Afile.DatelastModified If strModifyDay < dtmDate Then objFSO.DeleteFile (AFile) DeletedCount = DeletedCount + 1 End IfEnd SubIt is giving error on Line 30 char 2. Permission denied message.regards,RAvi
December 22nd, 2009 7:26am

I'm not sure which is line 30, but my guess would be the following:For Each TempFolder In MoreFoldersI have encountered similar errors on newer clients like Vista, where some folders are protected (even for Administrator users). I had to use error trapping to ignore the error, because I did not have permission to read the folders. In a similar situation I used code similar to below: On Error Resume Next For Each strfolder In objFolder.SubFolders If (Err.Number <> 0) Then Wscript.Echo "## Error accessing folder: " & objFolder.Path Wscript.Echo " Description: " & Err.Description Else On Error GoTo 0 Call SearchFiles(strFolder, arrExtensions, _ blnIncludeSub, strSearch, blnCase) End If On Error Resume Next Next On Error GoTo 0 My Sub SearchFiles is different from yours, but you get the idea. This snippet comes from the following VBScript program I use to search files for specified text strings:http://www.rlmueller.net/FindFiles.htmRichard MuellerMVP ADSI
Free Windows Admin Tool Kit Click here and download it now
December 22nd, 2009 9:19pm

thanks RIchard for replying once again. I got the solution, there was permissions related error so after providing permissions, issue got resolved.regards,RAvi bhanot
January 3rd, 2010 10:36am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics