C3sium Posted October 6, 2010 Posted October 6, 2010 ' Computer Logging VBS script ' ---------------------------------------------------------------' ' Defines Option Explicit Dim objFSO, objFolder, objShell, objTextFile, objFile, objNetwork Dim strDirectory, strFile, strText, strCompName, strUserName ' Get Detials Set objNetwork = WScript.CreateObject("WScript.Network") ' Sets Variables strCompName = objNetwork.ComputerName strUserName = objNetwork.UserName strDirectory = "\\mserver\NETLOGON\Logs" strFile = "\" & strCompName & ".txt" strText = "Logged On , "& strUserName & ", " & strCompName & ", " & NOW ' Create the File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") ' Check that the strDirectory folder exists If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFolder = objFSO.CreateFolder(strDirectory) End If If objFSO.FileExists(strDirectory & strFile) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFile = objFSO.CreateTextFile(strDirectory & strFile) End If set objFile = nothing set objFolder = nothing ' OpenTextFile Method needs a Const value ' ForAppending = 8 ForReading = 1, ForWriting = 2 Const ForAppending = 8 Set objTextFile = objFSO.OpenTextFile _ (strDirectory & strFile, ForAppending, True) ' Writes strText every time you run this VBScript objTextFile.WriteLine(strText) objTextFile.Close ' Close Script WScript.Quit Above is the script I am using to track who logs on to what machine and when. The problem is that they are unable to run at line 32 which is; Set objFile = objFSO.CreateTextFile(strDirectory & strFile) I have given permission for full control to the 'logs' folder fro everyone and on this file. But where am I going wrong? and How cand I fix it? Thank you in advance, C3sium
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now