Wus Posted June 4, 2005 Share Posted June 4, 2005 I remeber reading on the forums a while a go a code that would run itself in admin mode... cant find it now tho and I hoping someone else remembers it i know i could do a file install to a temp and run a 5 or so line scrpt to run that exe as a admin but isnt there a way to do this with only 1 prog... not 2 autoIT things pieced together Link to comment Share on other sites More sharing options...
PerryRaptor Posted June 5, 2005 Share Posted June 5, 2005 Checkout:http://www.sysinternals.com/Utilities/PsExec.htmlThe PsExec can do it. Link to comment Share on other sites More sharing options...
Wus Posted June 5, 2005 Author Share Posted June 5, 2005 I appreciate that you took the time to reply, no one else seemed to remeber... either thatr or I didnt explain myself clearly. what I meant was something like this: If ClipGet() <> "tr1gg3r" then ClipPut( "tr1gg3r" ) RunAsSet( $username , $FullDomainName, $Password) Run ( $ServPath & "start.exe" ) Exit EndIf That you can put at the beginning of a script and it will restart itself with certain user privileges... I couldnt ever find where it was on the forums and Im not sure if this is the same way as I saw it but it works just fine and dandy... Link to comment Share on other sites More sharing options...
/dev/null Posted June 5, 2005 Share Posted June 5, 2005 (edited) That you can put at the beginning of a script and it will restart itself with certain user privileges...Hm.. maybe something like this ?expandcollapse popupglobal $username = "YOUR NAME HERE"; <<=== change THIS !! global $domainname = @Computername; <<=== change THIS !! global $password = "YOUR PASSWORD HERE"; <<=== change THIS !! ;****************************************************** ;** Check commandline params ;****************************************************** if $CmdLine[0] > 0 then for $n = 1 to $cmdline[0] step 1 $param = $cmdline[$n] select ;****************************************************** ;** If script was started with param /ra, then restart ;** with RunAS and param /ra2 ;****************************************************** case $param = "/ra" RunAsSet( $username , $domainname, $password) Run(@ScriptDir & "\" & @ScriptName & " /ra2", @WorkingDir) exit ;****************************************************** ;** If script was started with param /ra2, then start ;** privileged code, as we are in stage 2 "ra2" of the ;** runas process ;****************************************************** case $param = "/ra2" _StartedWithRunAsSet() endselect next else ;****************************************************** ;** If script was started without params start unprivileged code ;****************************************************** _StartedNormally() endif func _StartedNormally() local $msg = "Started normally, without privileges... " & @CRLF $msg = $msg & "Path: " & @ScriptDir & @ScriptName & @CRLF $msg = $msg & "Params: " & $CmdLineRaw & @CRLF $msg = $msg & "User: " & @UserName msgbox(4096,"INFO", $msg) ;------------------------------------------------------------- ;- Your "normal" Code HERE ;------------------------------------------------------------- endfunc func _StartedWithRunAsSet() local $msg = "Started with privileges... " & @CRLF $msg = $msg & "Path: " & @ScriptDir & @ScriptName & @CRLF $msg = $msg & "Params: " & $CmdLineRaw & @CRLF $msg = $msg & "User: " & @UserName msgbox(4096,"INFO", $msg) ;------------------------------------------------------------- ;- Your "privileged" Code HERE ;------------------------------------------------------------- endfuncCheersKurt Edited June 5, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Wus Posted June 5, 2005 Author Share Posted June 5, 2005 err ... that looks like it... it'll take me a bit to figure out how it does what it does My way is simpler but your wa looks like a more "correct" solution to it Thanks a bunch for posting it Link to comment Share on other sites More sharing options...
/dev/null Posted June 5, 2005 Share Posted June 5, 2005 (edited) err ... that looks like it... it'll take me a bit to figure out how it does what it doesIt is really easy.* run: tool.exe ==> start without RunAsSet* run: tool.exe /ra ==> restart with RunAsSet. Runs: tool.exe /ra2 ; we need /ra2 to determine if the script was started with RunAsSet, as I don't know another way to determine this.Basically that's it. We could also change the script, to restart it with RunAsSet if there was no command line parameter at all. Then it would look like this...global $username = "YOUR NAME HERE"; <<=== change THIS !! global $domainname = @Computername; <<=== change THIS !! global $password = "YOUR PASSWORD HERE"; <<=== change THIS !! global $started_with_runas = 0 ;****************************************************** ;** Check commandline params ;****************************************************** if $CmdLine[0] > 0 then for $n = 1 to $cmdline[0] step 1 select case $cmdline[$n] = "/ra" $started_with_runas = 1 endselect next else ;****************************************************** ;** If script was started without params restart it with ;** RUnAsSet ;****************************************************** RunAsSet( $username , $domainname, $password) Run(@ScriptDir & "\" & @ScriptName & " /ra", @WorkingDir) exit endif ;****************************************************** ;** Exit if script was not started with /ra ;****************************************************** if $started_with_runas = 0 then exit endif ;------------------------------------------------------------- ;- Your "privileged" Code HERE ;-------------------------------------------------------------CheersKurt Edited June 5, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Killer Posted July 27, 2006 Share Posted July 27, 2006 try this code. This isn't my code. Got this from somewhere in the forum. Seems that I can't find it anymore. AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconHide", 1) Break(0) $USERNAME = "username" $PASSWORD = "password" $RUN = 0 ; run indicator ; retrieve the cycle from commandline If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, "your domain", $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 Link to comment Share on other sites More sharing options...
/dev/null Posted July 27, 2006 Share Posted July 27, 2006 try this code. This isn't my code. Got this from somewhere in the forum. Seems that I can't find it anymore. hm... have you actually seen the date of the original post? CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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