Jump to content

RegWrite with Administrative Permissions


srb
 Share

Recommended Posts

Hi,

Any suggestions how I can write a registry key with administrative permissions without calling an external program such as reg.exe?

I've tried using the RunAsSet function but this doesn't seem to apply to the RegWrite function

E.g.

RunAsSet("administrator", "AD Domain Name", "password", 2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\CUSTOMUPDATE\ZFD\AGENT\SP2", "UPDATENUMBER", "REG_DWORD", "10")

If the user has local admin permissions the the registry key is created/modified successfully.

If the user does NOT have local admin permissions the registry key is not created/updated.

Thanks

Link to comment
Share on other sites

  • Developers

what about?:

RunAsSet("administrator", "AD Domain Name", "password", 2)
Run(@AutoItExe & ' /AutoIt3ExecuteLine  "RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\CUSTOMUPDATE\ZFD\AGENT\SP2", "UPDATENUMBER", "REG_DWORD", "10")')

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

what about?:

RunAsSet("administrator", "AD Domain Name", "password", 2)
Run(@AutoItExe & ' /AutoIt3ExecuteLine  "RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\CUSTOMUPDATE\ZFD\AGENT\SP2", "UPDATENUMBER", "REG_DWORD", "10")')

:)

Jos,

Thanks for the reply.

I've added your code into my script but I get the following error:

Line -1:

Error: Unable to execute the external program.

Access is denied

Any ideas?

Thanks

Edited by srb
Link to comment
Share on other sites

  • Developers

Jos,

Thanks for the reply.

I've added your code into my script but I get the following error:

Line -1:

Error: Unable to execute the external program.

Access is denied

Any ideas?

Thanks

Are you running the script from a network share or from a local directory to which the AD account doesn't have enough rights ? Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Are you running the script from a network share or from a local directory to which the AD account doesn't have enough rights ?

The exe is running from a UNC path where the user has read only permissions.

I'll run the exe locally to verify that it's a network issue.

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I try to use the following code :

RunAsSet('Admin', 'AD domaine', 'Password', 0)
Run(@AutoItExe & ' /AutoIt3ExecuteLine  "RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Namtuk\wpe", "Message_AutoReply", "REG_SZ", "dormir")')

But I have the following error message box:

Line 1:

RegWrite(HKEY_LOCAL_MACHINE\SOFTWARE\Namtuk\wpe, Message_AutoReply, REG_SZ, dormir")

RegWrite(HKEY_LOCAL_MACHINE^ERROR

Error: Missing separator character after keyword

The code is used locally on the machine

Can you help me

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...