Link to home
Start Free TrialLog in
Avatar of Joe Howard
Joe HowardFlag for United States of America

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

Open in new window

Avatar of s_chilkury
s_chilkury
Flag of United States of America image

Are you getting any specific error?

If so, please post that error here.
Avatar of Joe Howard

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".
SOLUTION
Avatar of s_chilkury
s_chilkury
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should add the Scripting from the reference to your project

Where would I find it?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial