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   [ - ] Hide Comments

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.
Answer this question or Comment on this question for clarity

Answers

0
[8D]

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
Else
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
0
Many thanks
Answered 03/18/2005 by: Naffcat
Senior Purple Belt

Please log in to comment
0
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