Help on a RUNTIME ERROR Write to/Read from registry

Hello,

I can not find anywhere a working example to:

  • create a registry key (ex. “HKEY_LOCAL_MACHINE” -> “SOFTWARE\Example”)
  • write a string (ex. “Name” -> “John”)
  • then read that string

I want to test a simple program like:

index.php:

<?php $name="John"; exo_runhescriptcom ("UserMain.RegW|$name"); echo exo_return_hescriptcom("UserMain.RegR"); ?>

HEScript UserMain:

procedure RegW(Value: String);
begin
WriteRegStr(4, “SOFTWARE\Example”,“Name”,Value);
end;

function RegR: String;
begin
Result := ReadRegStr(4, “SOFTWARE\Example”,“Name”,“empty”);
end;

But I get a RUNTIME ERROR File library UserMain.hex: Cannot install into registry.
Key: SOFTWARE\Example Ident: Name Value John when evaluating instruction…

What am I missing here? Could you please show me a working example on this?
Thank you very much!

Liviu

It’s because you are not running with administrative rights, so the EXE can’t write to HKEY_LOCAL_MACHINE.

Solutions:

  • change the root key to HKEY_CURRENT_USER if you can.
  • require the EXE to ask for elevated rights at startup:

Hello! Thank you for the answer. I’ve realized in the meantime that I needed administrator rights for HKLM. But if I switch to HKCU, the registry key will not be available to all users, right?

In my Exeoutput version - 1.7.0 - I don’t find that option that you’ve showed in the screenshot (yours is: 2 beta). Is this option available in my version as well? I can’t seem to find it.

My solution so far was to create a HKLM entry using Paquet Builder (it has an option of writing in registry during install), then read the HKLM in the app built with Exeouptut. It’s working fine as the reading part, BUT I can write only to HKCU, which is still not great.

If you have an idea to help me with this, please let me know. Thank you!
Liviu

Only available in EXO 2.

For EXO 1.7 you can also edit the manifest in the EXE file with Resource Hacker to add administrative rights but it is cumbersome.