This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Unable to check if path exists using VB Script


Hi,

We are trying to access a set of files on a windows server to read the statistics present in these files. We are using the Windows Script Monitor component (vbscript) on SAM.

The files are present in a folder on the E drive on the target node. The folder is not shared on the network. However it is shared with the local user (same username as that of on the Solarwinds server connected to the domain controller. The target node is not connected to this domain controller) for read only. This local user has local logon permission on the target node. Solarwinds SAM is installed on a different subnet than this target node.

Here is our script.

Option Explicit
On Error Resume Next

if (WScript.Arguments.Count <> 1) then
WScript.Echo "Statistic: 0"

  WScript.Echo "Message: USAGE: <IP>

  WScript.Quit(1)
else
Dim fso, objDir, objFiles, path
path = "\\" & Wscript.Arguments(0) & "\E$\TempFolder\"
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(path) Then

   WScript.Echo "Statistic: 1"

   WScript.Echo "Message: Path Exists"

   Wscript.Quit(0)

else

  WScript.Echo "Statistic:2"

  WScript.Echo "Message: Path does not exists"

  WScript.Quit(1)

end if

When we run this script on SAM towards the target node, with the username as defined above, the output always evaluates to path does not exists.

Please help !!

Thanks.

  • The problem you're most likely running into is permissions/security. The reason why it works when run from your workstation or the SAM server itself is the script is using the permissions model of the user account you're logged in as. When the same script is run as a script monitor in SAM the script is run under the local system account of the machine which has no permission to access machines remotely. You will either need to add some form of impersonation to your script or leverage impersonation in the PowerShell script monitor to execute your script. This KB is short but explains the issue. Hope this helps.