Muscle Posted October 27, 2008 Share Posted October 27, 2008 (edited) hi @ all!!! i have a big problem. i wrote a script that needs admin rights on vista and xp. the problem is that i want to run the script with admin rights which are saved in a ini file. Then you can run the script on an account without admin rights with the saved user login data. Can anyone help me to realize that? I had an old script (i don´t know from where xD) that worked really good on xp - but it was an very old autoit version. Thanks!!!!! Muscle adminrights() Func adminrights() If Not IsAdmin() Then Opt("RunErrorsFatal", 0) ; Admin-Account user $run_admin_user = IniRead("data.ini", "Data", "account-user", "-") ; Admin-Account pass $run_admin_pass = IniRead("data.ini", "Data", "account-pass", "-") ; adminrights If Not $CMDLINE[0] Then RunAsSet($run_admin_user, @ComputerName, $run_admin_pass) Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') If @error = 1 Then MsgBox(48, "-", "Error") Else RunAsSet() EndIf Exit ElseIf $CMDLINE[1] <> '/admin' Then MsgBox(48, "-", "Error") Exit 1 EndIf EndIf EndFunc If IsAdmin() Then MsgBox(0, "", "NOW adminrights") Edited October 27, 2008 by Muscle Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2008 Developers Share Posted October 27, 2008 Check the Helpfile that came with the version you use now to see if you have a resent version of AutoIt3 that has a new syntax for running programs under different credentions.. it is now RunAs() Jos 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...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 thx jos! but the problem is that id doesn´t work ( i already tried). i have the newest autoit version (3.2.12.1) muscle Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2008 Developers Share Posted October 27, 2008 (edited) sounds logical when you run the script shown.... Now did you open that helpfile and check the syntax ? Edited October 27, 2008 by Jos 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...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 of course i did! i used: RunAs($run_admin_user, @ComputerName, $run_admin_pass, 0, @ComSpec) but then only 2 cmd windows open and that´s all muscle Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2008 Developers Share Posted October 27, 2008 You have defined @comspec there so that is what it runs -> the CMD.EXE. Just specify the proigram you want to execute. 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...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 then i use the script name it always restarts it self and nothing is happing. muscle Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2008 Developers Share Posted October 27, 2008 I assume you want something like this (untested): Func adminrights() If Not IsAdmin() Then ; Admin-Account user $run_admin_user = IniRead("data.ini", "Data", "account-user", "-") ; Admin-Account pass $run_admin_pass = IniRead("data.ini", "Data", "account-pass", "-") ; adminrights If Not $CMDLINE[0] Then RunAs($run_admin_user, @ComputerName, $run_admin_pass, 0,'"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') If @error = 1 Then MsgBox(48, "-", "Error") EndIf Exit ElseIf $CMDLINE[1] <> '/admin' Then MsgBox(48, "-", "Error") Exit 1 EndIf EndIf EndFunc ;==>adminrights 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...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 yeah something like this - but it´s not working (the scripts closes itself) :-( muscle Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2008 Developers Share Posted October 27, 2008 What about showing what you have now ...saves us from guessing 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...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 (edited) adminrights() Func adminrights() If Not IsAdmin() Then ; Admin-Account user $run_admin_user = "Blub" ; Admin-Account pass $run_admin_pass = "test" ; adminrights If Not $CMDLINE[0] Then RunAs($run_admin_user, @ComputerName, $run_admin_pass, 0,'"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') If @error = 1 Then MsgBox(48, "-", "Error") EndIf Exit ElseIf $CMDLINE[1] <> '/admin' Then MsgBox(48, "-", "Error") Exit 1 EndIf EndIf EndFunc ;==>adminrights If IsAdmin() Then MsgBox(0, "", "NOW adminrights") muscle Edited October 27, 2008 by Muscle Link to comment Share on other sites More sharing options...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 thx, i will try it direct muscle Link to comment Share on other sites More sharing options...
Muscle Posted October 27, 2008 Author Share Posted October 27, 2008 then i run it, i get a INVALID CMDLINE - Error ??? muscle 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