cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

New workaround for MEPCE Sync Tool in environments where registry editing is disabled by administrator

New workaround for MEPCE Sync Tool in environments where registry editing is disabled by administrator

Howdy everyone. I found and fixed a bug in MEP Content Editor Sync that required I run the tool as administrator in order to view available configurations. This isn't much of a problem for me as I have an admin account, but no one else on my team does.

 

After a little snooping in the logs I discovered that the problem is an effect of the following:

 

  1. %ProgramFiles%\Autodesk\MEP Content Editor Sync\resources\app\main.js calls reg.exe to get MachineGuid from HKLM:\\SOFTWARE\Microsoft\Cryptography
  2. The IT Security team at my org has disabled registry editing by non-admin users; Any calls to reg.exe are guaranteed to fail

As a fan of PowerShell I know that I'm able to read reg keys and values from a standard account using the command Get-ItemProperty. I made a few changes to main.js and now MEPCE Sync is working as expected from a standard user account (no admin privileges required).

 

Note: main.js is minified out of the box - I formatted the document with Prettier in order to debug. I've included line numbers as comments after formatting, but your mileage may vary. A quick search for reg.exe should help you locate the relevant code in your files.

 

main.js (Before)

case "win32": // ln: 17533
  return e
    .toString()
    .split("REG_SZ")[1]
    .replace(/\r+|\n+|\s+/gi, "")
    .toLowerCase();
// ...
win32: { // ln: 17577
  native: "%windir%\\System32",
  mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32",
}[i()] + "\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",

 

main.js (After)

// The case statement in this section is expecting 'REG_SZ' to be present
// in the value returned in the later section. My patch doesn't include
// that text in its return value, so we have to account for that here.
case "win32": { // ln: 17533
  var p = e.toString().split("REG_SZ");
  return (p.length > 1 ? p[1] : p[0])
    .replace(/\r+|\n+|\s+/gi, "")
    .toLowerCase();
}
// ...
win32: { // ln: 17577
  native: "powershell.exe -NoProfile -Command",
  mixed: "%windir%\\sysnative\\cmd.exe /c powershell.exe -NoProfile -Command",
}[i()] + " \"(Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Cryptography' -Name MachineGuid).MachineGuid\"",

 

I hope this helps someone else as much as it has helped me! Maybe someone from Autodesk can take a look at integrating this as a fallback in the next version of MEP Content Editor Sync.

 

My apologies if this is not the correct board for this sort of topic.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea