Joe Howard
asked on
Scripting not working
It seems that FileSystemObject doesn't exist anymore. Can someone help me fix this piece of code?
Imports Scripting
Public Function getSystemUID() As String
Dim enumerator As IEnumerator
Dim clsid As New Guid("0D43FE01-F093-11CF-8940-00A0C9054228")
Dim obj2 As FileSystemObject = DirectCast(Activator.CreateInstance(Type.GetTypeFromCLSID(clsid)), FileSystemObject)
Dim str As String = ""
Try
enumerator = obj2.Drives.GetEnumerator
Do While enumerator.MoveNext
Dim current As drive = DirectCast(enumerator.Current, Drive)
If ((current.DriveType = DriveTypeConst.Fixed) And current.IsReady) Then
str = (str & current.FileSystem)
Return (str & Conversions.ToString(current.SerialNumber))
End If
Loop
Finally
If TypeOf enumerator Is IDisposable Then
TryCast(enumerator, IDisposable).Dispose()
End If
End Try
Return str
End Function
ASKER
Scripting doesn't import (doesn't show-up in intellisense and is underlined in red indicating an error (no correction suggestions)).
And since it won't import Scripting, FileSystemObject, drive and DriveTypeConst cause "is not declared. it may be inaccessible due to its protection level".
And since it won't import Scripting, FileSystemObject, drive and DriveTypeConst cause "is not declared. it may be inaccessible due to its protection level".
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You should add the Scripting from the reference to your project
Where would I find it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If so, please post that error here.