Permission denied when attempting to post data to log file
Hi Everyone,
At the moment I am seeing a VB logon script error whenever I log into a Windows 2000 server network that I am connected to. Each time my machine logs on it attempts to write information to a log file on the server. However I am seeing an error that looks like the one below:
Error: Permission Denied
Code: 800A0046
Source: Microsoft VBScript runtime error
This is obviously a permissions challenge, however after assigning "modify" permissions to the log file and it's corresponding parent folder there has been no improvement, and the script still produces an error at logon. The script looks like the following:
Option Explicit
Dim fso, a, logFile, WSHNetwork
'change following log path and file name as needed
logFile = "\\...\Logs\Userlogons.log"
set fso = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Const OPEN_FILE_FOR_APPENDING = 8
'Following 3 lines just used for testing
'msgbox WSHNetwork.UserName
'msgbox WSHNetwork.ComputerName
'msgbox now()
Set a = fso.OpenTextFile(logFile, OPEN_FILE_FOR_APPENDING)
'write data
a.WriteLine ("LOGON" & "," & now() & "," & WSHNetwork.UserName & "," & WSHNetwork.ComputerName)
'close file
a.Close
Set fso = Nothing
WScript.Quit
The above code fails at line 15, char 1:
Set a = fso.OpenTextFile(logFile, OPEN_FILE_FOR_APPENDING)...
I have determined that this error is occuring because of the "FileSystemObject". However after changing permissions as mentioned above I have seen no improvement. If anybody has any suggestions regarding how to resolve this challenge they will be greatly appreciated.
Kind Regards
David
Re: Permission denied when attempting to post data to log file
its something to do with the permissions on either the client or the server, it could be that the server is set up so that users cant remotely access the resources. try running the script on a client who is logged in as an administrator?
Re: Permission denied when attempting to post data to log file
Chris,
Thanks for your message. I have determined that it is possible to log in as an Administrator, from a client machine, without causing the scripting error. It is only when logging in as a "general user" that the log file cannot be written to and the VBScript runtime error is produced. I have made the permissions for "general users" equal to "modify" which permits reading, writing, executing, etc. I have altered permissions on the log file and the folder that contains the log file. I do not believe that it is necessary to change permissions on the scripts themselves, however I may be wrong in that. Also the log files folder has sharing enabled.....is it possible that this is causing the error? Any further assistance will be greatly appreciated.
Kind Regards
Dave