0

Is there any way in VBA to determine whether the Scripting-Runtime aka scrrun.dll is disabled on a users system (here's a link on how to do that)?

I know, this is a very rare case, but it could be the case for exactly one client. There is another thread here but it's a little different.

Would you just go something like this?

Dim fso As Object

On Error Resume Next
  Set fso = CreateObject("Scripting.FileSystemObject")
On Error Goto 0

If fso Is Nothing then _
  MsgBox "Scripting runtime is not available on this system."

AHeyne
  • 3,377
  • 2
  • 11
  • 16
John Doe
  • 91
  • 7
  • This customer has the Scripting library disabled but Office installed? I am not sure if this makes sense... – FunThomas Jun 17 '21 at 12:34
  • I'm not at all a sophisticated programmer, more like a scientist which was the chosen one to write the VBA-stuff, so you're right and I'm probably totally wrong. But the debugger stops execution at the line where I check whether the script was started from a mapped drive via [this](https://www.vbforums.com/showthread.php?850527-How-can-I-obtain-the-UNC-path-for-a-Mapped-drive&s=b06f5c39a030b72859431d85b3cc9a50&p=5193341&viewfull=1#post5193341) approach . Since I see no other reason for failure (and it runs fine on every other machine) this was my suspect and at least now I know how to check it – John Doe Jun 17 '21 at 12:41

1 Answers1

2

Yes, I would use this approach, it's as short as it can be:

Public Function ScriptingRuntimeAvailable() As Boolean
    On Error Resume Next

    With CreateObject("Scripting.FileSystemObject"): End With

    ScriptingRuntimeAvailable = Err.Number = 0
End Function
AHeyne
  • 3,377
  • 2
  • 11
  • 16