cancel
Showing results for 
Search instead for 
Did you mean: 

How to get mega root besides from a mega object?

SOLVED
Occasional Contributor

How to get mega root besides from a mega object?

I wrote a script with the following code below.

 

Sub LoginLogger()

  Dim  pathFile, strInfo, userName, fso, fullpath, currentUser, mgRoot, myFile

  pathFile = "D:\Login Activity\loginLogs.txt"

 'Get Current User
  currentUser = megaRoot.GetObjectFromID(mgRoot.CurrentEnvironment.GetCurrentUserId)
  Set fso = CreateObject("Scripting.FileSystemObject")
  fullpath = fso.GetAbsolutePathName(pathFile)
  Set myFile = fso.OpenTextFile(fullpath, 8, True)
  myFile.WriteLine("Username:" &  currentUser.getProp("Name") & "|Repository:" & mgRoot.getProp("Name")& "|Date:" & Date() & "|Time:" & Time)
  Set myFile = nothing
  Set fso = nothing

End Sub

 

how can i get mega root( variable in red font)  in this scenario?

3 REPLIES
Frequent Contributor

Re: How to get mega root besides from a mega object?

Dear,

 

You can try a GetRoot() for a macro  or a .GetRoot directly in the current object for a macro as a Metacommand.

 

Regards,

Lionel Mazurié
Highlighted
Occasional Contributor

Re: How to get mega root besides from a mega object?

I am getting this error  after calling GetRoot() inside a  macro.

 

Thanks.

MEGA

Re: How to get mega root besides from a mega object?

Hello,

 

Use megaenv.getroot :

 

objMegaRoot = megaenv.getRoot

 

Regards,

 

Lionel