VBScript at Window Script Host, Check Folder Exists


The following script snippet is handy at checking whether a folder exists or not at Window Script Hosting Environment using VBScript.

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("C:\FSO") Then
    Set objFolder = objFSO.GetFolder("C:\FSO")
Else
    Wscript.Echo "Folder does not exist."
End If

The following does the same thing, if you prefer MS JScript Engine.

var objFSO = new ActiveXObject("Scripting.FileSystemObject");

if (objFSO.FolderExists("C:\\FSO")) {
	var objFolder = objFSO.GetFolder("C:\\FSO");
} else {
	WScript.Echo ("Folder does not exist.");
}

–EOF (The Ultimate Computing & Technology Blog) —

115 words
Last Post: Variable Scopes in VBScript at Windows Script Host
Next Post: Codeforces: A. Circle Line

The Permanent URL is: VBScript at Window Script Host, Check Folder Exists (AMP Version)

Leave a Reply