vb insert space

B0b_shiska
B0b_shiska used Ask the Experts™
on
Hello. I have a script that reads of a config file and retrieves file properties (file size,version&timestamp) and send the output to a txt file. How can i modify the script to include the following:
1. Currently timestamp and date are set to the current (when the script runs). Want it set to the last time the file being retrieved was modified.
2. include a space between each server output . For example, several servers are getting properties for adobe, others for java. Would like a space after the adobe output and before java.

Example output:
2/01/2009 2:02:19 PM: 10.x.x.1 c:\Program Files\adobe\name.exe 1.0.0.1
2660352 Bytes
2/01/2009 2:02:19 PM: 10.x.x.2 c:\Program Files\adobe\name.exe 1.0.0.1
2660352 Bytes                                                                                            
  (1 line space here)
2/01/2009 2:02:19 PM: 10.x.x.3 c:\Program Files\java\name.exe 1.0.0.1
2660352 Bytes
2/01/2009 2:02:19 PM: 10.x.x.4 c:\Program Files\java\name.exe 1.0.0.1
2660352 Bytes

3. Include a number count for each result.
Example:
1. 2/01/2009 2:02:19 PM: 10.x.x.4 c:\Program Files\java\name.exe 1.0.0.1
2660352 Bytes
2. 2/01/2009 2:02:19 PM: 10.x.x.5 c:\Program Files\java\name.exe 1.0.0.1
2660352 Bytes

4. Move the size output line (example below) to the same line. Currently, the file size in the output is showing up on the next line
 
Example:
2/01/2009 2:02:19 PM: 10.x.x.1 c:\Program Files\adobe\name.exe 1.0.0.1
2660352 Bytes
2/01/2009 2:02:19 PM: 10.x.x.2 c:\Program Files\adobe\name.exe 1.0.0.1
2660352 Bytes                                                                  
     (should be)
1. 2/01/2009 2:02:19 PM: 10.x.x.2 c:\Program Files\adobe\name.exe 1.0.0.1 2660352 Bytes
2. 2/01/2009 2:02:19 PM: 10.x.x.2 c:\Program Files\adobe\name.exe 1.0.0.1 2660352 Bytes

script:

Dim strServer
Dim strUsername
Dim strPassword
Dim StrFilename
Dim fConfig
dim objNetwork

Const ForReading = 1

Set objNetwork = CreateObject("WScript.Network")

strOutputFile = "C:\outputfile.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

set fConfig = objFSO.OpenTextFile("config.txt",ForReading, False)

Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

do until fconfig.atendofstream
      strLine = fconfig.readline
      If UCase(Left(strLine, 6)) = "SERVER" Then strServer = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "USERNAME" Then strUsername = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "PASSWORD" Then strPassword = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "FILENAME" Then strFileName = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If strServer <> "" And strUsername <> "" And strPassword <> "" And strFileName <> "" Then
            If Ping(strServer) = True Then
                  processfile strServer, strUsername, strPassword, "z:\" & StrFilename
            Else
                  objOutputFile.WriteLine strServer & " is offline."
            End If
            strServer = ""
            strUsername = ""
            strPassword = ""
            strFileName = ""
      End If
Loop

objOutputFile.Close
MsgBox "finished."

Function ProcessFile(strSvr, strUser, strPass, strFilePath)
      Dim strMsg, strVersion, timestamp
      On Error Resume Next
      objnetwork.removenetworkdrive "z:", True, True
      Err.Clear
    objnetwork.mapnetworkdrive "z:", "\\" & strSvr & "\C$", False, strUser, strPass
    If Err.Number <> 0 Then
          MsgBox "Error mapping to " & strSvr & ". Please check you can map to the server." & VbCrLf & "Error " & Err.Number & ": " & Err.Description
          Err.Clear
    Else
          On Error GoTo 0
            ' Make sure the file exists
            If objFSO.FileExists( strFilePath ) = False Then
                  strMsg = strFile & " - File not found. "
            Else
                  ' Get the Version of the File and put it in a Message String
                  strVersion = objFSO.GetFileVersion(strFilePath)
                  strMsg = strSvr & " " & strFilePath & " " & strVersion
                  strtimestamp = time()
            End If
      
            ' Write the Message string to the Output File (with a CR LF)
            objOutputFile.Write Now & ": " & strMsg & VbCrLf
            Set ffile = objfso.getfile(strFilePath)
            objoutputfile.writeline ffile.size & " Bytes"
            
      End If
      objnetwork.removenetworkdrive "z:", True, True
      Err.Clear
      On Error GoTo 0
End Function

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

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:


1.Get last data Modified

Dim f
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set f = objFSO.GetFile(strFilePath )
Msgbox f.DateCreated       'Return Date Created
Msgbox f.DateLastModified  'Returnd Date Modified


2. can you explain me the space between server output
why you can not add a " " when you write the output file?
Most Valuable Expert 2012
Top Expert 2014

Commented:
Hi there,

I haven't tested this, but I think I've done all four modifications for you.

1. Changed the output to write ffile.DateLastModified instead of Now.
2. This relies on you manually "ordering" the config file such that they are grouped by file name, then the script uses strPreviousFileName to determine when the file name changes, and if so, inserts a blank line.
3. This was helped by the above strPreviousFileName test, whereby we can also "reset" the counter back to the start for the next program group.
4. I removed the VbCrLf from the Write statement to avoid this file size starting on the next line.

As I said, I haven't tested it, so let me know if anything needs changing....I will be able to test it tomorrow.

Regards,

Rob.
Dim strServer
Dim strUsername
Dim strPassword
Dim StrFilename
Dim fConfig
Dim objNetwork
Dim strPreviousFileName
Dim intProgramCounter

strPreviousFile = ""
intProgramCounter = 0

Const ForReading = 1

Set objNetwork = CreateObject("WScript.Network")

strOutputFile = "C:\outputfile.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

set fConfig = objFSO.OpenTextFile("config.txt",ForReading, False)

Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

do until fconfig.atendofstream
      strLine = fconfig.readline
      If UCase(Left(strLine, 6)) = "SERVER" Then strServer = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "USERNAME" Then strUsername = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "PASSWORD" Then strPassword = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "FILENAME" Then strFileName = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If strServer <> "" And strUsername <> "" And strPassword <> "" And strFileName <> "" Then
            If Ping(strServer) = True Then
                  processfile strServer, strUsername, strPassword, "z:\" & StrFilename
            Else
                  objOutputFile.WriteLine strServer & " is offline."
            End If
            strServer = ""
            strUsername = ""
            strPassword = ""
            strFileName = ""
      End If
Loop

objOutputFile.Close
MsgBox "finished."

Function ProcessFile(strSvr, strUser, strPass, strFilePath)
	Dim strMsg, strVersion, timestamp
	On Error Resume Next
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	objnetwork.mapnetworkdrive "z:", "\\" & strSvr & "\C$", False, strUser, strPass
	If Err.Number <> 0 Then
		MsgBox "Error mapping to " & strSvr & ". Please check you can map to the server." & VbCrLf & "Error " & Err.Number & ": " & Err.Description
		Err.Clear
	Else
		On Error GoTo 0
		' Make sure the file exists
		If objFSO.FileExists( strFilePath ) = False Then
			strMsg = strFile & " - File not found. "
		Else
			' Get the Version of the File and put it in a Message String
			strVersion = objFSO.GetFileVersion(strFilePath)
			' Write the Message string to the Output File (with a CR LF)
			Set ffile = objfso.getfile(strFilePath)
			strtimestamp = ffile.DateLastModified
			If LCase(strPreviousFileName) <> LCase(Mid(strFilePath, InStrRev(strFilePath, "\") + 1)) Then
				intProgramCounter = 0
				objOutputFile.WriteLine ""
			End If
			intProgramCounter = intProgramCounter + 1
			objOutputFile.WriteLine intProgramCounter & ". " & strtimestamp & ": " & strSvr & " " & strFilePath & " " & strVersion & ffile.size & " Bytes"
			strPreviousFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
		End If
	End If
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	On Error GoTo 0
End Function

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

Author

Commented:
Hi Rob. A true genius. Worked perfectly. One last question. Several servers have numerous drives (c, d, e). At the moment, the script is only checking the c drive. How can i have it check the c, d and e drives for apps residing on the servers as well?

For example: Server 1 has adobe7.0 on the C drive and adobe 8.0 on the D drive. I would like to be able to check both drives for particular applications Thanks in advance.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Most Valuable Expert 2012
Top Expert 2014

Commented:
This depends on what your permissions would be on the server, with the given credentials in the log file.

If you were using credentials that had full admin rights on the remote machine, then you would have access to each "admin" share on each drive, being C$, D$, E$, etc.  Then, we could modify the script so that you include the full path in the config file, like
.....
FILENAME = C:\Program Files\Adobe\Reader\AcroRd32.exe
....
FILENAME = D:\Program Files\Adobe\Reader\AcroRd32.exe
....

And then, when it comes to mapping the Z Drive, just have it map to the C$ or D$ share respectively.

If that sounds feasible, let me know and I'll knock that out.

Regards,

Rob.

Author

Commented:
Hi Rob. The credentials being used in the config file are the ones that have full admin rights to all drives on the server. Modifying the script to include the full path in the config file sounds right. Many many thanks.
.....
FILENAME = C:\Program Files\Adobe\Reader\AcroRd32.exe
....
FILENAME = D:\Program Files\Adobe\Reader\AcroRd32.exe
....
Most Valuable Expert 2012
Top Expert 2014

Commented:
Sure, so modify the config file accordingly, and see how this goes.

Regards,

Rob.
Dim strServer
Dim strUsername
Dim strPassword
Dim StrFilename
Dim fConfig
Dim objNetwork
Dim strPreviousFileName
Dim intProgramCounter

strPreviousFile = ""
intProgramCounter = 0

Const ForReading = 1

Set objNetwork = CreateObject("WScript.Network")

strOutputFile = "C:\outputfile.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

set fConfig = objFSO.OpenTextFile("config.txt",ForReading, False)

Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

do until fconfig.atendofstream
      strLine = fconfig.readline
      If UCase(Left(strLine, 6)) = "SERVER" Then strServer = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "USERNAME" Then strUsername = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "PASSWORD" Then strPassword = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "FILENAME" Then strFileName = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If strServer <> "" And strUsername <> "" And strPassword <> "" And strFileName <> "" Then
            If Ping(strServer) = True Then
                  'processfile strServer, strUsername, strPassword, "z:\" & StrFilename
                  processfile strServer, strUsername, strPassword, strFilename
            Else
                  objOutputFile.WriteLine strServer & " is offline."
            End If
            strServer = ""
            strUsername = ""
            strPassword = ""
            strFileName = ""
      End If
Loop

objOutputFile.Close
MsgBox "finished."

Function ProcessFile(strSvr, strUser, strPass, strFilePath)
	Dim strMsg, strVersion, timestamp, strDriveLetter
	On Error Resume Next
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	strDriveLetter = Left(strFilePath, 1) & "$"
	objnetwork.mapnetworkdrive "z:", "\\" & strSvr & "\" & strDriveLetter, False, strUser, strPass
	If Err.Number <> 0 Then
		MsgBox "Error mapping to " & strSvr & ". Please check you can map to the server." & VbCrLf & "Error " & Err.Number & ": " & Err.Description
		Err.Clear
	Else
		On Error GoTo 0
		' Make sure the file exists
		If objFSO.FileExists(strFilePath) = False Then
			strMsg = strFile & " - File not found. "
		Else
			' Get the Version of the File and put it in a Message String
			strVersion = objFSO.GetFileVersion(strFilePath)
			' Write the Message string to the Output File (with a CR LF)
			Set ffile = objfso.getfile("Z:\" & Mid(strFilePath, 4))
			strtimestamp = ffile.DateLastModified
			If LCase(strPreviousFileName) <> LCase(Mid(Mid(strFilePath, 4), InStrRev(Mid(strFilePath, 4), "\") + 1)) Then
				intProgramCounter = 0
				objOutputFile.WriteLine ""
			End If
			intProgramCounter = intProgramCounter + 1
			objOutputFile.WriteLine intProgramCounter & ". " & strtimestamp & ": " & strSvr & " " & strFilePath & " " & strVersion & ffile.size & " Bytes"
			strPreviousFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
		End If
	End If
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	On Error GoTo 0
End Function

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

Author

Commented:
Hi Rob. I modified the conf file but receive the following error on Line 51 / char 2:       objnetwork.removenetworkdrive "z:", True, True
Error: This network connection does not exist.

If i leave the "on error resume next" option, the script finishes but the output file is blank. Please advice. Thanks in advance.
Most Valuable Expert 2012
Top Expert 2014

Commented:
I'm not able to test at the moment....I'll try it again tomorrow.

Author

Commented:
No problem. Thanks again.
Most Valuable Expert 2012
Top Expert 2014
Commented:
Hi, I've tested this a bit....give this a shot.

Regards,

Rob.
Dim strServer
Dim strUsername
Dim strPassword
Dim StrFilename
Dim fConfig
Dim objNetwork
Dim strPreviousFileName
Dim intProgramCounter

strPreviousFile = ""
intProgramCounter = 0

Const ForReading = 1

Set objNetwork = CreateObject("WScript.Network")

strOutputFile = "outputfile.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

set fConfig = objFSO.OpenTextFile("config.txt",ForReading, False)

Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

do until fconfig.atendofstream
      strLine = fconfig.readline
      If UCase(Left(strLine, 6)) = "SERVER" Then strServer = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "USERNAME" Then strUsername = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "PASSWORD" Then strPassword = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "FILENAME" Then strFileName = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If strServer <> "" And strUsername <> "" And strPassword <> "" And strFileName <> "" Then
            If Ping(strServer) = True Then
                  'processfile strServer, strUsername, strPassword, "z:\" & StrFilename
                  processfile strServer, strUsername, strPassword, strFilename
            Else
                  objOutputFile.WriteLine strServer & " is offline."
            End If
            strServer = ""
            strUsername = ""
            strPassword = ""
            strFileName = ""
      End If
Loop

objOutputFile.Close
MsgBox "Finished. Please see " & strOutputFile

Function ProcessFile(strSvr, strUser, strPass, strFilePath)
	Dim strMsg, strVersion, timestamp, strDriveLetter
	On Error Resume Next
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	strDriveLetter = Left(strFilePath, 1) & "$"
	objnetwork.mapnetworkdrive "z:", "\\" & strSvr & "\" & strDriveLetter, False, strUser, strPass
	If Err.Number <> 0 Then
		MsgBox "Error mapping to " & strSvr & ". Please check you can map to the server." & VbCrLf & "Error " & Err.Number & ": " & Err.Description
		Err.Clear
	Else
		On Error GoTo 0
		' Make sure the file exists
		intProgramCounter = intProgramCounter + 1
		If objFSO.FileExists("Z:\" & Mid(strFilePath, 4)) = False Then
			strMsg = strFilePath & " - File not found. "
		Else
			' Get the Version of the File and put it in a Message String
			strVersion = objFSO.GetFileVersion("Z:\" & Mid(strFilePath, 4))
			' Write the Message string to the Output File (with a CR LF)
			Set ffile = objfso.getfile("Z:\" & Mid(strFilePath, 4))
			strtimestamp = ffile.DateLastModified
			If LCase(strPreviousFileName) <> LCase(Mid(Mid(strFilePath, 4), InStrRev(Mid(strFilePath, 4), "\") + 1)) Then
				intProgramCounter = 1
				objOutputFile.WriteLine ""
			End If
			strMsg = intProgramCounter & ". " & strtimestamp & " " & strSvr & " " & strFilePath & " " & strVersion & " " & ffile.size & " Bytes"
		End If
		objOutputFile.WriteLine strMsg
		strPreviousFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
	End If
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	On Error GoTo 0
End Function

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

Author

Commented:
Hi Rob. Absolutely Pefect. Many many many thanks. Much appreciated.
Most Valuable Expert 2012
Top Expert 2014

Commented:
Great. Thanks for the grade.  Glad to help.

Rob.

Author

Commented:
Hi Rob. Quick question. Is there any way to insert space in the output file so it is aligned. For example, due to the different IP ranges and timestamp the result are displayed as follows: Thanks in advance.

1. 1/2/1998 2:22:03 PM 1x.x.x.xx C:\Program Files\name\name.exe 1.0.0.1 511 Bytes
2. 1/2/2000 1:42:01 PM 1x.x.x.xxx C:\Program Files\name\name.exe 1.0.1.1 233 Bytes
3. 2/2/2000 12:24:43 PM 1x.x.xx.xxx C:\Program Files\name\name.exe 1.0.0.1 22 Bytes
4. 2/2/2000 1:55:23 AM 1x.x.x.x C:\Program Files\name\name.exe 1.0.1.1 22345 Bytes
Most Valuable Expert 2012
Top Expert 2014

Commented:
Yeah, there's a couple of things we could do here.
1. We could implement a sort of "fixed width" situation, where each column is "padded" to a specific length with white space
2. We could write to a CSV file instead, and use a comma delimiter, so you can open it in Excel

They would be the two easiest options....which do you prefer?

Regards,

Rob.

Author

Commented:
Lets go with option # 2 (Excel). Many thanks again.
Most Valuable Expert 2012
Top Expert 2014

Commented:
OK, I think this should cover it.  Sorry, I got held up for a bit.

Regards,

Rob.
Dim strServer
Dim strUsername
Dim strPassword
Dim StrFilename
Dim fConfig
Dim objNetwork
Dim strPreviousFileName
Dim intProgramCounter

strPreviousFile = ""
intProgramCounter = 0

Const ForReading = 1

Set objNetwork = CreateObject("WScript.Network")

strOutputFile = "outputfile.csv"

Set objFSO = CreateObject("Scripting.FileSystemObject")

set fConfig = objFSO.OpenTextFile("config.txt",ForReading, False)

Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
objOutputFile.WriteLine """Counter"",""Time Stamp"",""Server"",""File Path"",""Version"",""Size"""

do until fconfig.atendofstream
      strLine = fconfig.readline
      If UCase(Left(strLine, 6)) = "SERVER" Then strServer = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "USERNAME" Then strUsername = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "PASSWORD" Then strPassword = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If UCase(Left(strLine, 8)) = "FILENAME" Then strFileName = Trim(Mid(strLine, InStr(strLine, "=") + 1))
      If strServer <> "" And strUsername <> "" And strPassword <> "" And strFileName <> "" Then
            If Ping(strServer) = True Then
				'processfile strServer, strUsername, strPassword, "z:\" & StrFilename
				processfile strServer, strUsername, strPassword, strFilename
            Else
            	intProgramCounter = intProgramCounter + 1
				If LCase(strPreviousFileName) <> LCase(Mid(Mid(strFileName, 4), InStrRev(Mid(StrFilename, 4), "\") + 1)) Then
					intProgramCounter = 1
					objOutputFile.WriteLine ""
				End If
				objOutputFile.WriteLine """" & intProgramCounter & """,""OFFLINE"",""" & strServer & """,""" & strFileName & """,""OFFLINE"",""OFFLINE"""
				strPreviousFileName = Mid(strFileName, InStrRev(StrFilename, "\") + 1)
            End If
            strServer = ""
            strUsername = ""
            strPassword = ""
            strFileName = ""
      End If
Loop

objOutputFile.Close
MsgBox "Finished. Please see " & strOutputFile

Function ProcessFile(strSvr, strUser, strPass, strFilePath)
	Dim strMsg, strVersion, timestamp, strDriveLetter
	On Error Resume Next
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	strDriveLetter = Left(strFilePath, 1) & "$"
	objnetwork.mapnetworkdrive "z:", "\\" & strSvr & "\" & strDriveLetter, False, strUser, strPass
	If Err.Number <> 0 Then
		MsgBox "Error mapping to " & strSvr & ". Please check you can map to the server." & VbCrLf & "Error " & Err.Number & ": " & Err.Description
		Err.Clear
	Else
		On Error GoTo 0
		' Make sure the file exists
		intProgramCounter = intProgramCounter + 1
		If objFSO.FileExists("Z:\" & Mid(strFilePath, 4)) = False Then
			strMsg = strFilePath & " - File not found. "
		Else
			' Get the Version of the File and put it in a Message String
			strVersion = objFSO.GetFileVersion("Z:\" & Mid(strFilePath, 4))
			' Write the Message string to the Output File (with a CR LF)
			Set ffile = objfso.getfile("Z:\" & Mid(strFilePath, 4))
			strtimestamp = ffile.DateLastModified
			If LCase(strPreviousFileName) <> LCase(Mid(Mid(strFilePath, 4), InStrRev(Mid(strFilePath, 4), "\") + 1)) Then
				intProgramCounter = 1
				objOutputFile.WriteLine ""
			End If
			strMsg = """" & intProgramCounter & "."",""" & strtimestamp & """,""" & strSvr & """,""" & strFilePath & """,""" & strVersion & """,""" & ffile.size & " Bytes" & """"
		End If
		objOutputFile.WriteLine strMsg
		strPreviousFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
	End If
	objnetwork.removenetworkdrive "z:", True, True
	Err.Clear
	On Error GoTo 0
End Function

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

Author

Commented:
Hi Rob. No need to apologize. Worked perfectly. Thank you so very much.
Most Valuable Expert 2012
Top Expert 2014

Commented:
Sure, no problem.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial