Solved

VB Script for Last Access Date for a DLL

Posted on 2014-04-30
3
326 Views
Last Modified: 2014-05-05
Hello,

I need a VB script that would read a computer name from a TXT file, look for a specific DLL file on that computer and return in a TXT file the computer name and the last access date for that file.  (in that case, i need to know when was the last date/time the VGX.DLL file was access, that file is locate in C:\Program Files\Common Files\Microsoft Shared\VGX).

Can you help me?

thanks
/mld
0
Comment
Question by:mldaigle1
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Hi, try this VBS code.

Regards,

Rob.

Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Program Files\Common Files\Microsoft Shared\VGX\vgx.dll"
strInput = "computers.txt"
strOutput = "log.csv"

Set objLog = objFSO.CreateTextFile(strOutput, True)
objLog.WriteLine """Computer"",""Last Accessed"""

Set objInput = objFSO.OpenTextFile(strInput, 1, False)
While Not objInput.AtEndOfStream
	strComputer = objInput.ReadLine
	If Ping(strComputer) = True Then
		strRemoteFile = "\\" & strComputer & "\" & Replace(strFile, ":", "$")
		If objFSO.FileExists(strRemoteFile) = True Then
			objLog.WriteLine """" & strComputer & """,""" & objFSO.GetFile(strRemoteFile).DateLastAccessed & """"
		Else
			objLog.WriteLine """" & strComputer & """,""<FILE NOT FOUND>"""
		End If
	Else
		objLog.WriteLine """" & strComputer & """,""<OFFLINE>"""
	End If
Wend
objLog.Close
objInput.Close

WScript.Echo "Done. Please see " & strOutput

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function

Open in new window

0
 

Author Closing Comment

by:mldaigle1
Comment Utility
Hi Rob,

This is exactly what i needed.  Now I just need to adapt your script to check if it is an english or french station and it will be perfect.

thanks again,
/mld
:)
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
No problem. Thanks for the grade. WMI should be able to help you get the language.

Rob.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now