我有一个vbs脚本,列出了Windows共享的路径。如果网络共享(路径)存在,我将如何获取路径并回显?我想我需要使用网络对象来查看share path = true,但我不知道怎么做?
任何帮助?
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
答案 0 :(得分:3)
'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