Sign in to follow this  
Followers 0
Niko

RunAs calling RegWrite

7 posts in this topic

Hi,

I was wondering if anyone can let me know what syntax I should be using to call RegWrite from RunAs.

I'd like to add a registry entry to HKLM and the script will be executing by a non-administrative user see.

I've searched lots of this but most of the answers relate to RunAsSet which seems to be obsolete now.

Thanks a lot,

Nik

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

I was wondering if anyone can let me know what syntax I should be using to call RegWrite from RunAs.

I'd like to add a registry entry to HKLM and the script will be executing by a non-administrative user see.

I've searched lots of this but most of the answers relate to RunAsSet which seems to be obsolete now.

Thanks a lot,

Nik

Just RanAs() a REG.exe command line. If you must run the native AutoIt RegWrite(), then you can run AutoIt3.exe or @ScriptFullPath with the /AutoIt3ExecuteLine parameter (see help file).

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for that, will give the REG.EXE method a try. :)

Thanks,

Nik

Just RanAs() a REG.exe command line. If you must run the native AutoIt RegWrite(), then you can run AutoIt3.exe or @ScriptFullPath with the /AutoIt3ExecuteLine parameter (see help file).

:)

Share this post


Link to post
Share on other sites

Hi,

OK, I still have some issues with attempting to use the REG IMPORT method. My code is:

RunAs ('administrator', @ComputerName, 'password', 0, 'reg import "C:\Path to Fix\ScriptData\EnableProcessing.reg"')

I have also tried the above command with a working directory but my REG file never gets imported. The command prompt window does appear and disappear but I can't tell what it says!

Thanks a lot for your help.

Cheers,

Nik

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

OK, I still have some issues with attempting to use the REG IMPORT method. My code is:

RunAs ('administrator', @ComputerName, 'password', 0, 'reg import "C:\Path to Fix\ScriptData\EnableProcessing.reg"')

I have also tried the above command with a working directory but my REG file never gets imported. The command prompt window does appear and disappear but I can't tell what it says!

Thanks a lot for your help.

Cheers,

Nik

Hi,

1) Navigate with Windows Explorer to <windowsdir>\system32\cmd.exe

2) Right Click on cmd.exe -> RunAs with the same credentials you are using in your AutoIT Script (see above RunAs..)

3) In cmd Box run: reg import "C:\Path to Fix\ScriptData\EnableProcessing.reg"

So you should have more information for debugging.

;-))

Stefan

P.S: You won't change or add key in HKCU?

Edited by 99ojo

Share this post


Link to post
Share on other sites

Hi,

I had actually already attempted to copy and paste my command into CMD.exe and that worked but have also just tried your suggestion of running CMD.exe as the local administrator and that too worked!

Unfortunately, the reg entries I'm updating are both per user and per machine so I have to update both HKCU and HKLM.

Cheers,

Nik

Hi,

1) Navigate with Windows Explorer to <windowsdir>\system32\cmd.exe

2) Right Click on cmd.exe -> RunAs with the same credentials you are using in your AutoIT Script (see above RunAs..)

3) In cmd Box run: reg import "C:\Path to Fix\ScriptData\EnableProcessing.reg"

So you should have more information for debugging.

;-))

Stefan

P.S: You won't change or add key in HKCU?

Share this post


Link to post
Share on other sites

Hi again,

Sorry, ignore me. I've been a complete ass and was checking the wrong key in the registry. The new REG IMPORT command was running successfully all along but as I was checking HKCU and not HKLM I wasn't seeing the change!

Doh!

Thanks again for all your help :)

Nik

Hi,

I had actually already attempted to copy and paste my command into CMD.exe and that worked but have also just tried your suggestion of running CMD.exe as the local administrator and that too worked!

Unfortunately, the reg entries I'm updating are both per user and per machine so I have to update both HKCU and HKLM.

Cheers,

Nik

Share this post


Link to post
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
Sign in to follow this  
Followers 0