Where can I find a VB script to check if a file exists on a remote machine, I check the MS script center but it's a bit of a maze these days.
0 Comments   [ + ] Show Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.



The easiest way is to use the FileExists method of the FileSystemObject object:

strComputer = "mypc001"
strDrive = "C"
strPathAndFile = "\windows\system32\shell32.dll"

Set objFSO = CreateObject("Scripting.FileSystemObject")
strCompleteFile = "\\" & strComputer & "\" & strDrive & "$" & strPathAndFile

wscript.echo "Looking for the following file: " & VBCRLF & strCompleteFile
If objFSO.FileExists(strCompleteFile) Then
msgbox "The below file does exist:" & VBCRLF & strCompleteFile
msgbox "The file does not exist: " & VBCRLF & strCompleteFile
End If
Answered 03/18/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
Many thanks
Answered 03/18/2005 by: Naffcat
Senior Purple Belt

Please log in to comment
Why not use Wise's Check if File or Dir exists action?

...just use a UNC name: \\MyTargetPC\MyShare[$]\Myfile.bla
Answered 04/22/2005 by: sean_c_roberts
Senior Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity