My first post as a SysAdmin (I am more used to C* programming).
What I am trying to do is create a script that will scan PCs on my network and check for a file and verify that it's size is correct.
If the file size is != 1,101,824bytes in size, the name of that PC should be logged - that's it.
I am just not too used to VBScripting and am not very aware of functions, how to call them, and etc.
This is what I have been trying to throw together for the last 20 minutes or so - kind of pressed for time...
Expand|Select|Wrap|Line Numbers
- '---------LogToFile Configuration---------
- 'NOTE: Copy the configuration section To
- 'the beginning of an existing script. The
- 'values specified here must be set before
- 'calling the LogToFile sub.
- 'You can disable logging globally by
- 'setting the bEnableLogging option to false.
- bEnableLogging = True
- 'Setting this to true will time stamp Each
- 'message that is logged to the log file
- 'with the current date and time.
- bIncludeDateStamp = True
- 'Specify the log file location here. Path
- 'must contain a trailing backslash. If you
- 'would like to log to the same location as
- 'the currently running script, set this
- 'value to "relative" or uncomment out the
- 'line below.
- sLogFileLocation = "C:\temp\log\"
- sLogFileLocation = "relative"
- 'Specify the log file name here.
- sLogFileName = "noble4jslog.txt"
- 'You can set whether or not you would like
- 'the script to append to an existing file,
- 'or if you would like it to overwrite
- 'existing copies. To overwrite set the
- 'sOverWriteORAppend variable to "overwrite"
- sOverWriteORAppend = "append"
- path = "C:\Program Files\Windows Media Connect 2\WMCCFG.exe"
- '-------END LogToFile Configuration-------
- Sub LogToFile(Message)
- 'LogToFile.vbs 10-18-07
- If bEnableLogging = False Then Exit Sub
- Const ForReading = 1
- Const ForWriting = 2
- Const ForAppending = 8
- Set oLogFSO = CreateObject("Scripting.FileSystemObject")
- If sLogFileLocation = "relative" Then
- Set oLogShell = CreateObject("Wscript.Shell")
- sLogFileLocation = oLogShell.CurrentDirectory & "\"
- Set oLogShell = Nothing
- End If
- sLogFile = sLogFileLocation & sLogFileName
- If sOverWriteORAppend = "overwrite" Then
- Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
- sOverWriteORAppend = "append"
- Else
- Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForAppending, True)
- End If
- If bIncludeDateStamp Then
- Message = Now & " " & Message
- End If
- oLogFile.WriteLine(Message)
- oLogFile.Close
- oLogFSO = Null
- End Sub
- Private Function FileLen(byVal path)
- Dim objFSO, objFile
- On Error Resume Next
- Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.GetFile(path)
- If Err Then
- FileLen = Null
- Else
- FileLen = CLng( objFile.Size )
- End If
- Set objFile = Nothing
- Set objFSO = Nothing
- On Error GoTo 0
- End Function
Any help you can give as soon as you can will be greatly appreciated.