23-03-2016 01:19 PM
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?
Solved! Go to Solution.
23-03-2016 05:46 PM
Hello,
Use megaenv.getroot :
objMegaRoot = megaenv.getRoot
Regards,
Lionel
23-03-2016 04:01 PM
23-03-2016 02:33 PM - edited 23-03-2016 02:34 PM
Dear,
You can try a GetRoot() for a macro or a .GetRoot directly in the current object for a macro as a Metacommand.
Regards,