문제

I have a vbs script that list the paths where there are Windows shares. How would I take the paths and echo if the network share(paths) exist? I think I need to use Network Object to see if share path = true, but I don't know how to?

Any help?

Dim objNetwork, strUserName, strNetworkPathFolder, strRevBackupServerPath,

Set objNetwork = CreateObject("WScript.Network")

strRevBackupServerPath="\\SERVER\"

strNetworkPathFolder="BackupPC_RevisonFileBackup$"

If  strRevBackupServerPath&strNetworkPathFolder = true then 
 WScript.Echo "Share Exists" 
Else
 WScript.Echo "Share Does Not Exists" 
End If
도움이 되었습니까?

해결책

'We don't need the WshNetwork object, it doesn't
'have any methods that are useful for your case.
'You also have strUserName and an extra comma at
'the end of your declarations.
Dim objFSO, strRevBackupServerPath, strNetworkPathFolder

'This is the filesystem object, we'll be using the
'FolderExists method.
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Here we use the FolderExists method to determine
'if the folder exists. Since the method returns
'a boolen true or false, we don't have to compare
'it to anything, it's evaluation is implicit.
If  objFSO.FolderExists(strRevBackupServerPath & strNetworkPathFolder) Then
  Wscript.Echo "Share Exists"
Else
  WScript.Echo "Share Does Not Exist" 
End If
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top