The following script snippet is handy at checking whether a folder exists or not at Window Script Hosting Environment using VBScript.
1 2 3 4 5 6 7 | 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 |
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.
1 2 3 4 5 6 7 | var objFSO = new ActiveXObject("Scripting.FileSystemObject"); if (objFSO.FolderExists("C:\\FSO")) { var objFolder = objFSO.GetFolder("C:\\FSO"); } else { WScript.Echo ("Folder does not exist."); } |
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) —
GD Star Rating
loading...
132 wordsloading...
Last Post: Variable Scopes in VBScript at Windows Script Host
Next Post: Codeforces: A. Circle Line