Niko Posted July 10, 2009 Share Posted July 10, 2009 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 10, 2009 Share Posted July 10, 2009 (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,NikJust 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 July 10, 2009 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 Link to comment Share on other sites More sharing options...
Niko Posted July 10, 2009 Author Share Posted July 10, 2009 Thanks for that, will give the REG.EXE method a try. Thanks,NikJust 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). Link to comment Share on other sites More sharing options...
Niko Posted July 13, 2009 Author Share Posted July 13, 2009 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 Link to comment Share on other sites More sharing options...
99ojo Posted July 13, 2009 Share Posted July 13, 2009 (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 July 13, 2009 by 99ojo Link to comment Share on other sites More sharing options...
Niko Posted July 13, 2009 Author Share Posted July 13, 2009 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,NikHi,1) Navigate with Windows Explorer to <windowsdir>\system32\cmd.exe2) 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.;-))StefanP.S: You won't change or add key in HKCU? Link to comment Share on other sites More sharing options...
Niko Posted July 13, 2009 Author Share Posted July 13, 2009 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 NikHi,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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now