And the best news of all is that this is really easy to do within VBA. Getting the value of any environment variable can be done using the built in .Environ$ function. Try the following:
Function ReturnOSPath() As String
'This function assumes that the "Comspec"
'variable File path is located on the boot drive
Dim strKRNL As String
strKRNL = VBA.Environ$("ComSpec")
On Error GoTo Err_Handler
ReturnOSPath = Mid$(strKRNL, 1, (VBA.Len(strKRNL) - 7))
Exit Function
Err_Handler:
ReturnOSPath = vbNull
End Function
Public Sub testospath()
MsgBox ReturnOSPath
End Sub
To use these, fire up the VBA editor within AutoCAD or any other VBA enabled application. Cut and paste the above code into the editor. Now call the "testospath" procedure to see how it works.