- Remove From My Forums
-
Question
-
I’m so close to get my script to work with a user, but I need your help.
I have a Terminal Server 2003 with policy restrictions. My users can’t even see how much megabytes they have in use. So I created the following script. It runs perfectly with an administrator account:—
Dim oFS, oFolder
Dim total
Dim message
set oFS = WScript.CreateObject(«Scripting.FileSystemObject»)
set oFolder1 = oFS.GetFolder(«\\server\share$»)
set oFolder2 = oFS.GetFolder(«\\server\share1$»)
set oFolder3 = oFS.GetFolder(«\\server\share2$»)
Wscript.Sleep 300
total = oFolder1.Size + oFolder2.Size + oFolder3.Size
message=MsgBox («Size: » & vbTab & oFolder1.Size /1024\1024 & «MB» & vbTab & » Path: » & vbTab & oFolder1.Path & Chr(10) _
& «Size: » & vbTab & oFolder2.Size /1024\1024 & «MB» & vbTab & » Path: » & vbTab & oFolder2.Path & Chr(10) _
& «Size: » & vbTab & oFolder3.Size /1024\1024 & «MB» & vbTab & » Path: » & vbTab & oFolder3.Path & Chr(10) _
& «Total: » & vbTab & total /1024\1024 & «MB»,64,»megabytes in use»)
—The problem I’m facing is that I can’t distribute it to my users because when this script runs as an user I receive this error:
Windows Script Host
Script: pathandname.vbs
Line: 9
Char: 1
Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime errorI’ve checked the users permission on the server\share’s and they have Full Control.
Also on the ACL on the script the user has Full Control.What else can I check?
Is there a setting in some GPO that denies users to run a .vbs?Please let me know when you need more information to solve this.
Cheers,
Yuri
Answers
-
Are you sure the users have permissions to ALL files and directories on the shares?
If there is as much as one file or folder to which the user hasn’t got at least «list contents» permission the script will fail with the above message.If you check the properties of the root of the share from explorer, first as an administrator and then as a user. Does it show the same amount of files/folders and the same size?
A difference here would indicate that the user doesn’t have permissions to everything.-
Marked as answer by
Tuesday, September 1, 2009 9:14 AM
-
Marked as answer by
I made a script that copying a file to a certain location.
I add the .vbs to taskschd.msc scheduled for make a .pst backup
but I get error message
Line: 91
Char: 7
Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error
<pre>
'Set the amount of pst-files you want to copy. Start counting at 0!
ReDim pst(1)
'Define the location of each pst-file to backup. Increase the counter!
pst(0) = "C:\Users\daniel.elmnas.TT\Documents\Outlook Files\de@teknotrans.se.pst"
pst(1) = "C:\Users\daniel.elmnas.TT\Documents\Outlook Files\de.pst"
'Define your backup location
BackupPath = "\\ttad-1\Gemensam\Outlook_Backup\Daniel Elmnäs"
'Keep old backups? TRUE/FALSE
KeepHistory = FALSE
'Maximum time in milliseconds for Outlook to close on its own
delay = 30000 'It is not recommended to set this below 8000
'Start Outlook again afterwards? TRUE/FALSE
start = TRUE
'===================STOP MODIFY====================================
'Close Outlook
Call CloseOutlook(delay)
'Outlook is closed, so we can start the backup
Call BackupPST(pst, BackupPath, KeepHistory)
'Open Outlook again when desired.
If start = TRUE Then
Call OpenOutlook()
End If
Sub CloseOutlook(delay)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'If Outlook is running, let it quit on its own.
For Each Process in objWMIService.InstancesOf("Win32_Process")
If StrComp(Process.Name,"OUTLOOK.EXE",vbTextCompare) = 0 Then
Set objOutlook = CreateObject("Outlook.Application")
objOutlook.Quit
WScript.Sleep delay
Exit For
End If
Next
'Make sure Outlook is closed and otherwise force it.
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set objOutlook = Nothing
set colProcessList = Nothing
End Sub
Sub BackupPST(pst, BackupPath, KeepHistory)
Set fso = CreateObject("Scripting.FileSystemObject")
If KeepHistory = True Then
ArchiveFolder = Year(Now) & "-" & Month(Now) & "-" & Day(Now)
BackupPath = BackupPath & ArchiveFolder & "\"
End If
If fso.FolderExists(BackupPath) = False Then
fso.CreateFolder BackupPath
End If
For Each pstPath in pst
If fso.FileExists(pstPath) Then
fso.CopyFile pstPath, BackupPath, True
End If
Next
Set fso = Nothing
End Sub
Sub OpenOutlook()
Set objShell = CreateObject("WScript.Shell")
objShell.Run "Outlook.exe"
End Sub
</pre>
Could someone help me to solve this?
Thank you in advance
asked Apr 24, 2015 at 12:11
3
Seems like you schedule the script.
You need to start the task with a user that executes the script which has rights on the PST file, as well as on the path where you store the backup. Running it with the system account won’t be enough.
There are better ways to backup PST files also, I use a Ruby script to synchronise a local copy with a backup copy, is runs on PST’s more than 10GB big without problem, might be a problem if you would do it with a copy like this.
You need to backup the copy on a backup medium also because when the PST has errors (and all big PST have) you copy the errors to the backup and could lose both.
Also, you do the following
BackupPath = "\\ttad-1\Gemensam\Outlook_Backup\Daniel Elmnäs"
...
BackupPath = BackupPath & ArchiveFolder & "\"
Where is the \ between the two first variables ?
answered Oct 14, 2015 at 19:43
peterpeter
41.8k5 gold badges64 silver badges108 bronze badges
EDITED: Change the permissions of the folder.
- In windows explorer, navigate to the folder where the PST file is located.
- In the left pane of windows explorer, right click on the folder where the PST file is located, select «Properties».
- Select the «Security» tab
- Click the button «Edit» to change permissions.
- Click «Add»
- In the object names to select box, enter «everyone» (no quotes).
- Click «Check Names», everyone should become capitalized and underlined.
- Click «Ok»
- Select «Everyone» from the list of Groups or user names.
- In the «Permissions for Everyone» list, make sure «Read & Execute, List folder contents and Read, in the allow column are checked, click «Apply»
- Click Ok.
NOTE: By doing this, anyone who has access to this computer can access the folder. You might consider only adding your login to the computer to the list of Groups or usernames instead of Everyone. You may have to repeat the above steps on the PST file(s) in question.
Original Post:
I ran the script here, testing for various issues and it ran without problems. At this point I believe the issue is rights and permissions to either the source or destination folder (or the files you are backing up). By default, the user’s themselves don’t have access to Outlooks data files. You would need to add «read» permissions to the files in question (PST,OST, and so on) or the full folder.
In reality, just backing up the PST files isn’t enough to restore an Outlook configuration; you would need all of the files.
You can Try this:
'===================================================================
'Description: VBS script to backup your pst-files.
'
'Comment: Before executing the vbs-file, set the location of outlook
' folder you want to backup and
' the backup location (this can also be a network path).
' See the URL below for more configuration instructions and
' how to create a Scheduled Task for it.
'
' Original author : Robert Sparnaaij
' Modified: Fred Kerber
' version: 1.1
' website: http://www.howto-outlook.com/downloads/backupscript.htm
' Changes:
' Changed var types; changed to backup full folder and not just pst files.
'===================================================================
'===================BEGIN MODIFY====================================
'Define the folder location of Outlook's data files.
sOutlookDataPath = "C:\Users\FKerber.CORP\AppData\Local\Microsoft\Outlook\"
'Define your backup location
sBackupPath = "E:\Outlook Backup\"
'Keep old backups? TRUE/FALSE
bKeepHistory = TRUE
'Maximum time in milliseconds for Outlook to close on its own
iDelay = 30000 'It is not recommended to set this below 8000
'Start Outlook again afterwards? TRUE/FALSE
bStart = True
'===================STOP MODIFY====================================
'Close Outlook
Call CloseOutlook(iDelay)
'Outlook is closed, so we can start the backup
Call BackupOutlook(sOutlookDataPath, sBackupPath, bKeepHistory)
'Open Outlook again when desired.
If bStart = TRUE Then
Call OpenOutlook()
End If
Sub CloseOutlook(iDelay)
Set objWMIService = GetObject("winmgmts:" &_
{impersonationLevel= impersonate}!\\.\root\cimv2")
'If Outlook is running, let it quit on its own.
For Each oProcess in objWMIService.InstancesOf("Win32_Process")
If StrComp(oProcess.Name,"OUTLOOK.EXE",vbTextCompare) = 0 Then
Set objOutlook = CreateObject("Outlook.Application")
objOutlook.Quit
WScript.Sleep delay
Exit For
End If
Next
'Make sure Outlook is closed and otherwise force it.
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set objOutlook = Nothing
Set colProcessList = Nothing
End Sub
Sub BackupOutlook(sOutlook, sBackupPath, bKeepHistory)
Set ofso = CreateObject("Scripting.FileSystemObject")
If bKeepHistory = True Then
sArchiveFolder = Year(Now) & "-" & Month(Now) & "-" & Day(Now)
sBackupPath = sBackupPath & sArchiveFolder & "\"
Else
For Each oFile In ofso.GetFolder(sBackupPath).Files
ofso.DeleteFile oFile.Path, True
Next
End If
If ofso.FolderExists(sBackupPath) = False Then
ofso.CreateFolder sBackupPath
End If
For Each oFile In ofso.GetFolder(sOutlook).Files
If ofso.FileExists(oFile.Path) Then
ofso.CopyFile oFile.Path, sBackupPath, True
End If
Next
Set ofso = Nothing
End Sub
Sub OpenOutlook()
Set objShell = CreateObject("WScript.Shell")
objShell.Run "Outlook.exe"
End Sub
answered Oct 14, 2015 at 18:29
Fred KerberFred Kerber
1554 silver badges13 bronze badges
0
I had a similar problem trying to delete files with VBS. I assume that as with my case: The source of the problem is that the script is trying to perform some operation on a file or folder that has a Read-only Attribute. To solve this manually you could left click -> properties -> unclick the Read-Only Attribute then the file/folder should be copied by the script. To solve the problem with VBS: I make the assumption that file/folder is set to Read-Only because there is a programme currently using them.
One: we can just skip files/folders set to read-only this time and hope to get them next time the script runs. For this we first check if file/folder is read-only (I got this from here: https://social.technet.microsoft.com/Forums/ie/en-US/7382d452-1ef9-404a-8874-48d38fcfe911/vbscript-verify-if-a-file-is-readonly?forum=ITCG), if not then we perform the copy operation.
Sub BackupPST(pst, BackupPath, KeepHistory)
'........
For Each pstPath in pst
If fso.FileExists(pstPath) Then
If not (fso.GetFile(pstPath).Attributes AND 1) Then 'if item is not read-only
fso.CopyFile pstPath, BackupPath, True
End If
End If
Next
Set fso = Nothing
End SubSub
Two: At the very least this should prevent you from getting the error. But if the script never moves the files even after running a number of times then chances are that the files (you are trying to move) are always in read only and you should change Attribute of the file (you are trying to move) in your script before calling the copy function, see how to do that here: https://devblogs.microsoft.com/scripting/how-can-i-change-a-read-only-file-to-a-read-write-file/
answered Apr 5, 2022 at 8:59
The Microsoft VBScript runtime error: Permission denied 800A0046, may faced while trying to install or uninstall a program or driver on your computer. The error 800A0046 is commonly caused because you ‘ll try to install a program on your computer without having administrative privileges or because you have enabled the User Account Control (UAC) on Windows 7 or Vista based computers.
In most cases the VBScript runtime error 800A0046, is occurred whenever you try to install the «Windows Installer Clean Up» utility, in order to remove a program from the system that you cannot uninstall by using the normal way (Programs and features).
This article contains two(2) methods to fix the «Permission denied 800A0046» Windows Script Host Error, on Windows 7 or Vista.
How to bypass the Windows Script Host «Permission Denied – Code 800A0046».
Before applying the methods below to resolve the VBScript Runtime 800A0046 error, first make sure that you have logged on as Administrator on your system,
Method 1: DISABLE User Account Control (UAC).
In order to disable the UAC (User Account Control):
1. Go to Start > Control Panel.
2. Open User Accounts.
3. Click at Change User Account Control settings.
4, Move the slider on the left to Never notify and click OK.
5. Restart your computer.
6. After restart, install (or uninstall) the program that caused the 800A0046 error.
Method 2: RUN the Installer (Setup.exe) as Administrator
In order to install a program as administrator:
1. Right click at the program (installer) that you ‘re trying to install and click Run as Administrator.
That’s all folks! Did it work for you?
Please leave a comment in the comment section below or even better: like and share this blog post in the social networks to help spread the word about this solution.
If this article was useful for you, please consider supporting us by making a donation. Even $1 can a make a huge difference for us.
I get the following error:
Microsoft VBScript runtime error ‘800a0046’ Permission denied
When running a classic asp application.
The error is here: (in the CreateTextFile
line)
Dim myFSO
set myFSO = Server.CreateObject("Scripting.FileSystemObject")
myFSO.CreateTextFile(fName)
I know I can get around this problem by giving «Full control» to the «Everyone» user. This is a publicly accessible folder on our server, so I worry that this is a security risk?
I would prefer to be able to give full permission to someone like «IIS_IUSRS», but this doesn’t work. It’s as if it’s a different user being used for this.
Is this a security risk? Anyone know what I should be doing?
asked Oct 15, 2012 at 9:44
2
You should either find the anonymous user of your specific website and give write access to that specific user or set the application pool identity of the website to Local System so that the website would have permission.
To find your IUSR also known as the anonymous user in IIS7, open your website in IIS in Features View and go to Authentication and edit Anonymous Authentication.
answered Nov 5, 2012 at 7:32
1
Troubleshooting Code 800A0046 – Permission Denied
Code 800A0046 is a straightforward error to solve. The secret is to read the Windows Script Error message carefully, then check the access control list to see who has permission to use the page, or use the device.
- Introduction to Error Code 800A0046
- Example 1: Script to map a printer
- Example 2: Error 800A0046 When You Install Visual Studio
- Permissions Analyzer Free Tool
‡
Introduction to Error 800A0046
Code 800A0046 is runtime error that is more likely to occur with an .ASP file than a .VBS. You could be trying to connect to SQL, IIS or Exchange. However, my example of is taken from printer permission problem sent in by Keith S.
The Symptoms You Get With Error 800A0046
When you get a pop-up message box. Put on your detective hat, and pay close attention to the line number. Error 800A0046 is a runtime error, so the problem is likely to outside your script, there could be something the matter with permissions on an application server.
The Cause of Error 800A0046
In the example above, Line 6: is the source of the error. Char 1: is not always very useful as the error could be anywhere on the line, and WSH still blames char 1.
The cause of error 800A0046 is likely to be read-only permissions on some aspect of your server. The Source: tells us that this is a runtime error, therefore the syntax is probably o.k.
The Solution
If its Exchange, then check the MailRoot and Pickup folder permissions. If its IIS check the permissions to run scripts. If its SQL check the execute permissions on the services.
The solution in the printer problem below would be to change the share permissions on the HP6L printer share.
Example 1: Script to map a printer
In this example, the user does not have permission to install the HP6L printer. Tell the truth, an example script is not that useful with Error 800A0046 as you cannot see the permissions!
‘ VBScript to create a local printer mapped to a network server
‘ Guy Thomas February 2010.
Option Explicit
Dim netPrinter
Set netPrinter = CreateObject(«WScript.Network»)
netPrinter.AddWindowsPrinterConnection «\\ServerPrn\HP6L»
Guy Recommends: Permissions Analyzer – Free Active Directory Tool
I like thePermissions Monitor because it enables me to see quickly WHO has permissions to do WHAT. When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!
Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource. Give this permissions monitor a try – it’s free!
Download Permissions Analyser – Free Active Directory Tool
Example 2: Error 800A0046 When You Install Visual Studio 6.0 (Also other Microsoft Products)
When you install Visual Studio you get the following message.
Permission denied: ‘CreateObject’
/Retail/include/global_siteconfig_lib.asp, line 194
Once again it’s a permissions problem on the Windows\system32 folder. Another idea is to try the useful Free Permissions Analyzer.
Example 3: ASP on IIS (Kindly sent in by a reader)
The way we got error 800A0046 was running ASP on IIS under Server 2003R2. Someone wrote a debug routine that did an OpenTextFile from a FileSystemObject; I think what happened was there were multiple simultaneous attempts to open that file.
Example 4: Constantly Writing to File
Dim FSO
Dim oFS
CONST F_ATTR_RONLY = 1
Set FSO = CreateObject(«Scripting.FileSystemObject»)
Set oFS = FSO.GetFile(«d:\test\o2\test.png»)
IF oFS.Attributes AND F_ATTR_RONLY ‘check if bit 1 is set – read only
THEN
‘do nothing
ELSE
FSO.CopyFile «d:\test\o1\test.png», «d:\test\o2\»
END IF
The problem was: the file is written into the sourcelocation every 10 seconds. This is done by a Closed Source Software i have no way of editing. It seems like i get the error (line 11) every time i try to READ the sourcefile while it is being written/created.
Sadly the only solution i found was to run the script with
c:\windows\system32\wscript.exe «c:\{path to script}» //B
preventing the errornotice.
I have found no way to check if the file is currently being modified except for try and error.
See More Windows Update Error Codes 8004 Series
• Error 800A101A8 Object Required •Error 800A0046 •Error 800A10AD •Error 800A000D
• Error 80048820 •Error 800A0401 •Review of SolarWinds Permissions Monitor
• Error 80040E14 • Error 800A03EA • Error 800A0408 • Error 800A03EE
Guy Recommends: WMI Monitor and It’s Free!
Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems. Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free. Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.
Download your free copy of WMI Monitor
Do you need additional help?
- For interpreting the WSH messages check Diagnose 800 errors.
- For general advice try my 7 Troubleshooting techniques.
- See master list of 0800 errors.
- Codes beginning 08004…
- Codes beginning 08005…
- Codes beginning 08007…
- Codes beginning 0800A…
Give something back?
Would you like to help others? If you have a good example of this error, then please email me, I will publish it with a credit to you:
If you like this page then please share it with your friends