JoymanyMahn Posted May 7, 2007 Share Posted May 7, 2007 I know how run a particular task in AutoIt as an Admin using RunAsSet, but I can't find a way to run an entire script. For example, I would like for Non-Admin users to be able to launch an AutoIt executable file that modifies two entries in the HKLM part of the Registry. The following works--but obviously only in Admin mode. Any assistance would be appreciated. CODE $Reg01_keyname = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" $Reg01_valuename = "DisablePagingExecutive" $Reg01_type = "REG_DWORD" $Reg01_value = "00000001" RegWrite ( $Reg01_keyname, $Reg01_valuename, $Reg01_type, $Reg01_value) If @error Then MsgBox(4096,"", "Error: " & $Reg01_keyname) Else MsgBox(4096, "Result for " & $Reg01_valuename, "Successfully wrote value: " & $Reg01_value & _ @LF & "To name: " & $Reg01_valuename & _ @LF & "Under key: " & $Reg01_keyname) EndIf ;===Force Windows to Unload DLLs from Memory $Reg02_keyname = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AlwaysUnloadDLL" $Reg02_valuename = "" $Reg02_type = "REG_SZ" $Reg02_value = "1" RegWrite ( $Reg02_keyname, $Reg02_valuename, $Reg02_type, $Reg02_value) If @error Then MsgBox(4096,"", "Error: " & $Reg02_keyname) Else MsgBox(4096, "Result for " & $Reg02_valuename, "Successfully wrote value: " & $Reg02_value & _ @LF & "To name: " & $Reg02_valuename & _ @LF & "Under key: " & $Reg02_keyname) EndIf Link to comment Share on other sites More sharing options...
Tripredacus Posted May 7, 2007 Share Posted May 7, 2007 I had this problem also, so I made 2 scripts. One is the one that does things (like edit the registry). The other is a wrapper that executes the actual app. Dim $Username, $Password $Username = "Administrator" $Password = "Password" RunAsSet ( $Username, @Computername, $Password ) RunWait ( "registry.exe" ) The program "registry.exe" is a separate script that actually has your code in it that you posted. Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
Developers Jos Posted May 7, 2007 Developers Share Posted May 7, 2007 Just restart the script with admin credentials .. $USERNAME = "Administrator" $PASSWORD = "Secret" $RUN = 0 ; run indicator ; retrieve the cycle from commandline If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) Run('"' & @ScriptFullPath & '" " 1"') If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode") Exit EndIf ; commands go here that require Administrator rights 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 More sharing options...
JoymanyMahn Posted May 7, 2007 Author Share Posted May 7, 2007 Thank you so much JdeB! This worked perfectly! Link to comment Share on other sites More sharing options...
Tripredacus Posted May 8, 2007 Share Posted May 8, 2007 (edited) Just restart the script with admin credentials .. $USERNAME = "Administrator" $PASSWORD = "Secret" $RUN = 0 ; run indicator ; retrieve the cycle from commandline If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) Run('"' & @ScriptFullPath & '" " 1"') If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode") Exit EndIf ; commands go here that require Administrator rights I guess that would work too, but its really the same thing I posted except you added a messagebox. Edited May 8, 2007 by Tripredacus Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
herewasplato Posted May 8, 2007 Share Posted May 8, 2007 ...but its really the same thing I posted...JdeB's method does not require two scripts. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted May 8, 2007 Developers Share Posted May 8, 2007 I guess that would work too, but its really the same thing I posted except you added a messagebox.Principal is the same but a lot easier to accomplish what the op wanted I would say ... 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 More sharing options...
Tripredacus Posted May 8, 2007 Share Posted May 8, 2007 JdeB's method does not require two scripts.OH I see I did not read the comment on the last line. I will have to try this in the future. Twitter | MSFN | VGCollect 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