mrrlg Posted May 26, 2004 Posted May 26, 2004 I need to install some software on users machines without granting them administrative rights. I have tried the following command and it doesn't seem to work. RunAsSet ("Administrator", "Domain", "Password") Where am I going wrong?
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 (edited) I need to install some software on users machines without granting them administrative rights. I have tried the following command and it doesn't seem to work.RunAsSet ("Administrator", "Domain", "Password")Where am I going wrong?That should do the trick ... the subsequent RUN or RUNWAIT statements will execute with those credentials...What is the error you get ?? Edited May 26, 2004 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 The next line in the script is Sleep (2000) DirRemove ("C:\test") Sleep (1000) If not DirMove("C:\program files\oda\passport", "C:\test") Then MsgBox(4096, "Cannot Move Directory", "The directory could not be moved. Check if a program is still running from this directory") Exit(1) Endif BlockInput (1) The message box Cannot move directory pops up and when I check, the C:\test file is still there and the contents of the Passport folder have not been moved.
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 RunASSet is only for Run and Runwait !!! If you need to do other autoit3 commands then you need to restart the script before executing them. Something like this works after you compiled it: $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 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.
Administrators Jon Posted May 26, 2004 Administrators Posted May 26, 2004 RunASSet is only for Run and Runwait !!! If you need to do other autoit3 commands then you need to restart the script before executing them. Something like this works after you compiled it: $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 EndIfHeh, that is some cunning code. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
SlimShady Posted May 26, 2004 Posted May 26, 2004 Really interesting and definitely something I'll use. Thanks for the code.
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 (edited) Heh, that is some cunning code. The basic idea was made by Larry quit a while ago....just worked it out this way.Have used this piece of code already many times for installs of patches etc.. Edited May 26, 2004 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 Thanks for the code, not sure where to place it in the script so I started the script off with it, now when I execute this line If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] I get the error Variable used without being declared.
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 (edited) Thanks for the code, not sure where to place it in the script so I started the script off with it, now when I execute this line If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] I get the error Variable used without being declared.on $run ? - Just put the whoile code i posted before your script.... - Compile it ..... - then run it.... Edited May 26, 2004 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.
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 Thats a build-in variable... Can you post the script as you have it now ? 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 $__msgbox = MsgBox ( 4, 'AOOA MIS Dept', 'This Script will install the Latest Version of Passport for Windows. Do you want to Continue?' ) if NOT ( $__msgbox = 7 ) then EndIf RunAsSet ("Administrator", "Domain", "Password") $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 thescript 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 Sleep (2000) DirRemove ("C:\test") Sleep (1000) DirMove ("C:\program files\oda\passport", "C:\test1") If not DirMove("C:\program files\oda\passport", "C:\test1") Then MsgBox(4096, "Cannot Move Directory", "The directory could not be moved. Check if a program is still running from this directory") Exit(1) Endif
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 (edited) This works for me without an error : $RUN = 0 If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] ; set to admin mode If $RUN = 0 Then $__MSGBOX = MsgBox(4, 'AOOA MIS Dept', 'This Script will install the Latest Version of Passport for Windows. Do you want to Continue?') If NOT ($__MSGBOX = 6) Then Exit If Not IsAdmin() Then RunAsSet("Administrator", "Domain", "Password") ; start thescript 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 Sleep(2000) DirRemove("C:\test") Sleep(1000) If Not DirMove("C:\program files\oda\passport", "C:\test1") Then MsgBox(4096, "Cannot Move Directory", "The directory could not be moved. Check if a program is still running from this directory") Exit (1) EndIf EDIT: remove the double RunAsSet Edited May 26, 2004 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 I took just your script, copied it into Crimson Editor, compiled it, ran it from the network share as a user and now I get the variable used without being declared at the line RunAsSet($USERNAME, @ComputerName, $Password)
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 yea... you need to specify those or hardcode them like you did in your example... Updated the earlier posted script..... 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 (edited) JdeB, I edited the script to follow your updates, if I leave the RunAsSet line as "Administrator", "Domain", "Password" then I receive an error invalid user name or password. If I edit this line to reflect the correct domain and password for the Administrator account then the script fails on the DirMove line. Yet I can move this directory on my own. Edited May 26, 2004 by mrrlg
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 Are you sure the DirRemove("C:\test") works... If the files already exists DirMove will fail unless you specify: DirMove("C:\program files\oda\passport", "C:\test1",1) 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.
mrrlg Posted May 26, 2004 Author Posted May 26, 2004 C:\text is deleted, C:\text1 is created, The contents of C:\program files\oda\passport are not moved. Is dirmove the wrong command to use?
SlimShady Posted May 26, 2004 Posted May 26, 2004 C:\text is deleted, C:\text1 is created, The contents of C:\program files\oda\passport are not moved. Is dirmove the wrong command to use?You can use the filecopy function. Example from the help file:FileCopy("C:\*.au3", "D:\mydir\*.*") ; method to copy a folder (with its contents) DirCreate("C:\old") FileCopy("C:\old\*.*", "C:\new\")
Developers Jos Posted May 26, 2004 Developers Posted May 26, 2004 C:\text is deleted,C:\text1 is created,The contents of C:\program files\oda\passport are not moved. Is dirmove the wrong command to use?Should work, did you check if it already existed and try it with the ,1 parameter ? 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.
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