Read from Registry in a script

Hi all

I have attached an example (where you probably need to adapt the registry key).

  1. They very first time I get an error/nothing happens because reg.exe is too slow. The result file huhu1.txt is created, but too late for the DOpus script.
  2. If I manipulate huhu1.txt, the next time the file is not overwritten. But the syntax seems to be OK because from a DOS shell the result file is always overwritten.

So, runCommand seems not to fork correctly. Is there a workaround or do I make something wrong? If yes, can someone point out the proper way.


function OnClick(data) {
  var dlg = DOpus.Dlg;
  var doCmd = DOpus.NewCommand;
  var FSUtil = DOpus.FSUtil;
  var StringTools = DOpus.Create.StringTools();

  doCmd.RunCommand("reg.exe export \"HKLM\\SOFTWARE\\WOW6432Node\\Apache Software Foundation\\Procrun 2.0\\Tomcat8\\Parameters\\Java\" \"c:/huhu1.txt\"");

  var myText = FSUtil.OpenFile("c:\\huhu1.txt").Read();
  myText = StringTools.Decode(myText,"auto"); //[utf16 be|utf16 le|auto]
  // var result = myText.match(/"Jvm"="(.+?)"/);

  dlg.window = DOpus.Listers(0);
  dlg.template = "dialog";
  dlg.detach = true; 
  dlg.Control("edit1", "dialog").value = myText;

  while (true) {
    msg = dlg.GetMsg();
    if (!msg.result) { break; }

Exporting the registry data to a file and then parsing the file makes things a lot harder than they need to be.

Windows provides a RegRead function for reading registry values directly:

Use var WshShell = new ActiveXObject ("WScript.Shell") to create the WSH object in an Opus sript, then use it as in the examples on that page.

Thanks Leo
"Exporting the registry data .... a lot harder than they need to be".

I agree - but I have nothing found here or in the manual. Probably I was not carefully enough. I have adapted what I needed and it works with charme.


The Opus manual only covers the scripting objects/methods which Opus provides. Windows provides lots of useful objects as well. It's worth having a look through Microsoft's documentation (or one of the other sites about VBScript/JScript) for other useful things.