Solved

VB Script for Last Access Date for a DLL

Posted on 2014-04-30
3
333 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
ID: 40033739
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
ID: 40041769
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
ID: 40041776
No problem. Thanks for the grade. WMI should be able to help you get the language.

Rob.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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