tAKTelapis Posted November 28, 2006 Posted November 28, 2006 (edited) Hey Everyone Figured i would edit this into proper english, i was in a real rush when i wrote it, and figured someone may be able to help. I have installed a piece of software onto the Computer Labs on the school i work for, and as usual, have copied the profile of the user i installed it as, into the Default User profile, so that certain software settings follow. However, when the program first runs for a user, it writes information to the HKCU\Software\ of the registry. Student accounts do not have permission to write to the registry, so this prevents the software from running. I have a list of all the keys which i need to create, and create an AutoIT script with a "RegWrite()" statement for each key, when ran as myself (i have admin rights) it creates the keys correctly. If i add a RunAsSet("Administrator", @computername, "password"), The keys fail to show up, my best guess is that they are writing the the HCKU\Software registry entry for the user "Administrator" instead of the Currently Logged in User. (i have attempted this with all three possible flags, all have the same result) My Next idea was to RuAs admin, and then: Run("Regedit.exe /s c:\RegistryKey.reg") Running the Regedit command with the switches via a Run prompt directly works fine, however, calling it from AutoIT in this manner fails in all cases, there is no error, the command runs, but it does not actually produce an effect, the registry information does not get added. Anyone have any other ideas on this? anyway to elevate the currently logged in user to admin for the purpose of adding the info then removing that user from admin? /tAK Edited November 28, 2006 by tAKTelapis
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 Is there a sollution for this mather. I'm also trying to write to the HKCU (for the placesbars) But on my pc with my account it works fine (admin) but for the users it wouldn't works (because HKCU is not writable) Anyone an idea? "You cannot solve a problem with the mind that created it" (Albert Einstein)
Developers Jos Posted December 28, 2006 Developers Posted December 28, 2006 What about: - check if user has admin rights - if not: added the current user to the Administrators group, do what needs to be done after which you remove the user id from the administrators group. 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.
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 Ok, sounds easy.But how can I add an user to the local admin group with autoit?I've found on autoit site some code, but there is no way to add the user to the admin group "You cannot solve a problem with the mind that created it" (Albert Einstein)
Developers Jos Posted December 28, 2006 Developers Posted December 28, 2006 (edited) Ok, sounds easy.But how can I add an user to the local admin group with autoit?I've found on autoit site some code, but there is no way to add the user to the admin groupSimple way is to run these commands because you can easily run it with an Account that has admin rights :Net Localgroup Administrators "Domain\UserID" /AddNet Localgroup Administrators "Domain\UserID" /Delete Edited December 28, 2006 by JdeB 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.
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 problem is that the program will be running on a pc without the admin rights. so the AD user who is working on that machine doesn't have any rights (unless the right to work ) He can start my script to change the placesbar. Everything works fine if the user had local admin rights. If I try your example with net localgroup ... if receive system error 5 has occured acces is denied but maybe I have to run this line as administrator? "You cannot solve a problem with the mind that created it" (Albert Einstein)
Developers Jos Posted December 28, 2006 Developers Posted December 28, 2006 problem is that the program will be running on a pc without the admin rights.so the AD user who is working on that machine doesn't have any rights (unless the right to work )He can start my script to change the placesbar. Everything works fine if the user had local admin rights.If I try your example with net localgroup ...if receive system error 5 has occuredacces is deniedbut maybe I have to run this line as administrator?Isn't that what I said ? You do:RunAsSet("admin","Domain", "Password")RunWait(@ComSpec & " /c Net Localgroup Administrators "Domain\UserID" /Add")RunAsSet()RunWait("regedit.....")RunWait(@ComSpec & " /c Net Localgroup Administrators "Domain\UserID" /Delete") 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.
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 (edited) i tried to put it all together in an script and come up with this errorthe code i have for this thingRunAsSet("adminuser", @ComputerName, "adminpass")run("net localgroup Administrator "domain\user" /add"RunAsSet()maybe i' doing something wrong? I think I surely do something wrongSorry, didn't see that you already post something. My mistake. I will give it a try. Edited December 28, 2006 by Steven Vandenhoute "You cannot solve a problem with the mind that created it" (Albert Einstein)
Developers Jos Posted December 28, 2006 Developers Posted December 28, 2006 i tried to put it all together in an script and come up with this errorthe code i have for this thingmaybe i' doing something wrong? I think I surely do something wrongMultiple errors in this line : run("net localgroup Administrator "domain\user" /add"- Missing closing bracket ...(thats the error reported.- Missing @comspec- Should be runWait- Wrong " mixRunWait(@comspec & ' /c net localgroup Administrator "domain\user" /add',"",@sw_Hide) 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.
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 I think I'm stupid. Even with your lines of code I'm unable to get it right this is the new error. And if I'm not mistaking it is the same error "You cannot solve a problem with the mind that created it" (Albert Einstein)
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 (edited) I found it. I need to use ' instead of " Thankx man, you gave me the sollution for my last problem Edited December 28, 2006 by Steven Vandenhoute "You cannot solve a problem with the mind that created it" (Albert Einstein)
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 (edited) how can I use this command with a variable?I tried to use it like this$adminuser="user"$adminpass="pass"$domainuser="domain\"&@usernameRunAsSet($adminuser,@ComputerName, $adminpass)RunWait(@ComSpec & ' /c Net Localgroup Administrators $domainuser /Add')RunAsSet();RunWait("regedit.....");RunWait(@ComSpec & " /c Net Localgroup Administrators "" /Delete")but it would not work.Am I doing something wrong? Edited December 29, 2006 by Steven Vandenhoute "You cannot solve a problem with the mind that created it" (Albert Einstein)
Developers Jos Posted December 28, 2006 Developers Posted December 28, 2006 how can I use this command with a variable?I tried to use it like thisbut it would not work.Am I doing something wrong?Looks to me you need some basic training here .... Concatenation of literals and variables ...RunWait(@ComSpec & ' /c Net Localgroup Administrators ' & $domainuser & ' /Add') 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.
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 well no, I've tried it like you write it, but doesn't work "You cannot solve a problem with the mind that created it" (Albert Einstein)
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 Ok, I know what I was doing wrong. I had coded also the " before and after the domain\user and it seems that that is not necessary. only thing what i have to find now is a way to activate the user as admin without an logoff (user is in admin group, but is not activated) "You cannot solve a problem with the mind that created it" (Albert Einstein)
Steven Vandenhoute Posted December 28, 2006 Posted December 28, 2006 I'm sorry to bodder you again, but what you say doesn't work (at least not for me) If I use it with variables it doesn't work. Do I the same but hardcoded it works. "You cannot solve a problem with the mind that created it" (Albert Einstein)
Sundance Posted January 9, 2007 Posted January 9, 2007 (edited) Hi Steven, i've programmed this today and it worked for me. It's based on the hint from JdeB. You can additionally use the $AdminDomain variable for the net command. (I've forgot this one ) greets Sundance #include <string.au3> $AdminPWD = _StringEncrypt(0,"xxxxxxxxxxxx","xxxxx") $AdminName = "Admin" $AdminDomain = "domain" RunAsSet($AdminName,$AdminDomain,$AdminPWD) RunWait(@ComSpec & " /c net localgroup administrators 'domain\" & @UserName & "' /add") RunAsSet() RunWait(@ComSpec & " /c reg import " & @ScriptDir & "\somereg.reg") RunAsSet($AdminName,$AdminDomain,$AdminPWD) RunWait(@ComSpec & " /c net localgroup administrators 'domain\" & @UserName & "' /delete") Edited January 9, 2007 by Sundance
Fme Posted January 30, 2007 Posted January 30, 2007 (edited) Hi all,Quite new to this world,I'd like to do the same thing but for Windows NT4 WorkstationAnybody got solution ?? Edited January 30, 2007 by Fme
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