FileExists(Filename)

Hi

Have an old VB script and I would like to convert it to javascript
Can anybody help ?

The script just check if a file is pressent in a folder.

VB Script:
DIM FSO, Filename
Filename=Watch.GetVariable(“FiledirAndFilename”)
set FSO = CreateObject(“Scripting.FileSystemObject”)
if (FSO.FileExists(Filename)) then
Script.ReturnValue = 1
else
Script.ReturnValue = 0
end if

Javascript I can’t get to work.
var Filename=Watch.GetVariable(“FiledirAndFilename”);
set FSO = CreateObject(“Scripting.FileSystemObject”); – Fails
if (FSO.FileExists(Filename)) {
Script.ReturnValue = 1
}
else {
Script.ReturnValue = 0
}

var fso = new ActiveXObject(“Scripting.FileSystemObject”);

1 Like