When calling this method it just returns the error, system variable is undefined.
I am currently trying to make a GPO logon script that checks to see if a directory exists and if it doesn't create it.
I am just very confused as there are so many visual basic variants and I can't seem to find what I need. Is the visual basic I need vbs or vb.net or vb scrips im honestly lost.
System.IO.Directory just returns me an error and I have tried many others but receive the same error.
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