Skip to content

Instantly share code, notes, and snippets.

@mitaken
Last active May 8, 2023 00:35
Show Gist options
  • Save mitaken/ba1b7cf606b6820c41a04c88977a65ec to your computer and use it in GitHub Desktop.
Save mitaken/ba1b7cf606b6820c41a04c88977a65ec to your computer and use it in GitHub Desktop.
Option Explicit
Call WScript.Quit(Main())
Function Main()
Main = 0
Dim ObjShell, StrPaths, AryPaths
Set ObjShell = WScript.CreateObject("WScript.Shell")
StrPaths = ObjShell.ExpandEnvironmentStrings("%PATH%")
Call Debug.WriteLine(StrPaths)
AryPaths = Split(StrPaths, ";")
Dim ObjFSO, StrPath, StrNormalizePath, StrNotExistsPath
Set ObjFSO = WScript.CreateObject("Scripting.FileSystemObject")
StrNotExistsPath = ""
For Each StrPath In AryPaths
If Len(StrPath) > 0 Then
StrNormalizePath = ObjShell.ExpandEnvironmentStrings(StrPath)
Call Debug.WriteLine(StrNormalizePath)
If Not ObjFSO.FolderExists(StrNormalizePath) Then
StrNotExistsPath = StrNotExistsPath + vbCrLf + StrNormalizePath
End If
End If
Next
If StrNotExistsPath <> "" Then
Main = 1
Call MsgBox(StrNotExistsPath, vbOKOnly + vbExclamation, "Folder Not Exists in Path")
End If
Set ObjFSO = Nothing
Set ObjShell = Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment