当调用此方法时,它只返回错误,系统变量未定义。
我当前正在尝试创建一个GPO登录脚本,用于检查目录是否存在以及是否未创建该目录。
我只是非常困惑,因为有这么多的visual basic变体,我似乎找不到我需要的。是我需要的visual basic,vbs,vb.net,或者vb脚本,我真的迷路了。
System.IO.Directory只是给我返回了一个错误,我已经尝试了很多其他的方法,但都收到了同样的错误。
Option Explicit
Dim l: l = "Z:"
Dim s: s = "\\TEST-SERVER\Shared Folder"
Dim Network: Set Network = CreateObject("WScript.Network")
Dim CheckDrive: Set CheckDrive = Network.EnumNetworkDrives()
Dim DriveExists: DriveExists = False
Dim i
'check to see if drive exists
For i = 0 to CheckDrive.Count - 1
If CheckDrive.Item(i) = l Then
DriveExists = True
End If
Next
'if drive doesnt map it
If DriveExists = False Then
Network.MapNetworkDrive l, s, False
Else
'drive already mapped
End If
Dim strDirectory
strDirectory = "C:\Screensaver"
If(Not System.IO.Directory.Exists(strDirectory)) Then
System.IO.Directory.CreateDirectory(strDirectory)
End If发布于 2019-04-16 01:25:10
System.*是用于VB.net的,但是脚本的其余部分看起来像是想要成为VBS。VBS可以使用FileSystemObject与文件夹进行交互。
在您尝试创建目录的部分尝试执行以下操作:
Dim strDirectory
strDirectory = "C:\Screensaver"
Set fso = CreateObject("Scripting.FileSystemObject")
If(Not fso.FolderExists(strDirectory)) Then
fso.CreateFolder(strDirectory)
End Ifhttps://stackoverflow.com/questions/55693652
复制相似问题