' MapNetworkDrive.vbs
' VBScript to open a text file on a computer across the network and write
' Author Lance Simms 
' Credit to Guy Thomas http://computerperformance.co.uk/
' 
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strFileName
Dim objFileSystem, objOutputFile
Dim strOutputFile
Dim MyArray(2)
Dim text
Const ForReading=1

strDriveLetter = "Z:"
strRemotePath = "\\Old_duder\TEMP_DOCS"
strFilename="\test.txt"

MyArray(0)=strDriveLetter
MyArray(1)=strFilename

strOutputFile=Join(MyArray,"")

'MsgBox(strOutputFile)

' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method.  Result J: drive
Set objNetwork = WScript.CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

set objFileSystem= CreateObject("Scripting.fileSystemObject")
set objOutputFile= objFileSystem.OpenTextFile(strOutputFile, ForReading)

text=objOutputFile.Readline
'objOutputFile.Writeline("Hello world (" & Now &")")
objOutputFile.Close

Set objFileSystem=Nothing

MsgBox(text)

WScript.Quit(0)

'WScript.Quit

' End of script.