hcstarck Posted July 30, 2004 Share Posted July 30, 2004 Is it possible to use RegWrite by a non admin user? I have tried to use the RunAsSet and then setting the admin, but that only applies to the Run methods I believe. Do I have to log off as the user and then back on as the admin? Thanks Link to comment Share on other sites More sharing options...
ezzetabi Posted July 30, 2004 Share Posted July 30, 2004 If anything else fail you can always create a .reg file on the fly with FileWrite() and Run('regedit /s thatfile.reg') after setting Runasadmin and finally delete the reg. Link to comment Share on other sites More sharing options...
hcstarck Posted July 30, 2004 Author Share Posted July 30, 2004 Interesting solution. Anything thats not quite that messy? I'll get starting on that in the meantime though, thanks. Link to comment Share on other sites More sharing options...
CyberSlug Posted July 30, 2004 Share Posted July 30, 2004 Hmm.... There needs to be some sort of RunAsSet for registry functions.... Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
ezzetabi Posted July 30, 2004 Share Posted July 30, 2004 Here the messy idea coded and tested. $Adminuser = "Administrator" $Adminpass = "Password" $Domain = "Domain" ;Copy and paste the .reg file adding ' at beginning of lines and ' & @crlf &_ at the end ;Be careful about the 4096 chars limit of the lines. FileWrite(@TempDir & "\TheReg.reg",_ 'Windows Registry Editor Version 5.00' & @crlf &_ @crlf &_ '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]' & @crlf &_ '"Tweak UI"="RUNDLL32.EXE TWEAKUI.CPL,TweakMeUp"' & @crlf) RunAsSet($adminuser,$domain,$adminpass) RunWait(@windowsdir & '\regedit.exe /s "' & @tempdir & '\TheReg.reg"','') RunAsSet() FileDelete(@tempdir & "\thereg.reg") Link to comment Share on other sites More sharing options...
hcstarck Posted July 30, 2004 Author Share Posted July 30, 2004 Thanks ezzetabi. Thats roughly what I came up with. I just forgot to use the crlf in the keys so the reg wasn't running, Link to comment Share on other sites More sharing options...
Administrators Jon Posted July 30, 2004 Administrators Share Posted July 30, 2004 JdeB has a great script somewhere that detects if it is running under admin mode, and if not restarts itself with RunAsSet. Very nifty and means you only need to have a single script. Deployment Blog:Â https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming:Â https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
ezzetabi Posted July 30, 2004 Share Posted July 30, 2004 (edited) Great idea! Untested code: $Name = "Name of the script" $Adminuser="" $Adminpass="" $Domain="" If WinExists($Name) Then WinClose($Name);In the case the other script is still running AutoItWinSetTitle($Name) If Not IsAdmin() Then RunAsSet($Adminuser,$Domain,$adminpass) If @Compiled Then Run(@scriptfullpath) Else Run(@comspec ' /c cmd start ' & FileGetShortname(@scriptfullpath),'',@SW_HIDE) EndIf RunAsSet() Exit EndIf ;Real script there.... Edited July 30, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
emmanuel Posted July 30, 2004 Share Posted July 30, 2004 JdeB has a great script somewhere that detects if it is running under admin mode, and if not restarts itself with RunAsSet. Very nifty and means you only need to have a single script.And here it is. $RUN = 0 If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] ; set to admin mode If $RUN = 0 Then If Not IsAdmin() Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) ; start the script program (itself) again but now in Adminmode...so all done tasks will run in Adminmode Run('"' & @ScriptFullPath & '" " 1"') If @error = 1 Then MsgBox(48, "Error", "cannot start Admin mode.") EndIf Exit EndIf EndIf "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
ezzetabi Posted July 30, 2004 Share Posted July 30, 2004 Mine looks better... Link to comment Share on other sites More sharing options...
CyberSlug Posted July 30, 2004 Share Posted July 30, 2004 Cool. This might be worth putting in the FAQ. Another gem is the script that resumes after the computer reboots. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
emmanuel Posted July 30, 2004 Share Posted July 30, 2004 Mine looks better...well, maybe you'd want to add it to the wiki? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
ezzetabi Posted July 31, 2004 Share Posted July 31, 2004 Cool. This might be worth putting in the FAQ. Another gem is the script that resumes after the computer reboots. <{POST_SNAPBACK}>Some thing like this: Dim $Reboot = "False", $c = 0 If $cmdline[0] > 1 Then For $c to 1 to $cmdline[0] If $cmdline[$c] = "/reboot" Then $Reboot = "True" ExitLoop EndIf Next EndIf If $Reboot == "False" ;The starting script is there If @compiled = 1 Then RegWrite("HKLM\SoftWare\Microsoft\Windows\CurrentVersion\RunOnce",_ AutoItWinGetTitle(),"reg_sz",@scriptfullpath & ' /reboot') Else RegWrite("HKLM\SoftWare\Microsoft\Windows\CurrentVersion\RunOnce",_ AutoItWinGetTitle(),"reg_sz",'%comspec% /c start ' & GetShortname(@scriptfullpath) & ' /reboot') Shutdown(6) Else ;the resumed script is there EndIf Link to comment Share on other sites More sharing options...
ezzetabi Posted July 31, 2004 Share Posted July 31, 2004 well, maybe you'd want to add it to the wiki? <{POST_SNAPBACK}>What is that?!? Link to comment Share on other sites More sharing options...
sugi Posted August 2, 2004 Share Posted August 2, 2004 I've set up the wiki to make it easier to create a tutorial. Everybody can add text to it without having knowledge of HTML. Link to comment Share on other sites More sharing options...
emmanuel Posted August 2, 2004 Share Posted August 2, 2004 I've set up the wiki to make it easier to create a tutorial. Everybody can add text to it without having knowledge of HTML. <{POST_SNAPBACK}>To elaborate, wiki is a web authoring system, the largest use of it, that I know of, is wikipedia the free online encyclopedia created and maintained by it's users. I'm attracted to the communal aspect of editing and updating... "I'm not even supposed to be here today!" -Dante (Hicks) 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