Messi Posted December 13, 2010 Share Posted December 13, 2010 Hi, I have found the following script which will install the .exe file with a different set of credentials in case that the current user does not have admin rights. In my case the crendentials have to be the local administrator user/passowrd which have been entered in the code below. #NoTrayIcon #RequireAdmin $USR_USERNAME = 'Administrator' $USR_PASSWORD = 'Password' $PKG_FILENAME = @TempDir & '\Package.exe' FileInstall('Package.exe', $PKG_FILENAME) If IsAdmin() Then RunWait($PKG_FILENAME & ' /silentswitches', '', @SW_HIDE) Else RunAsWait($USR_USERNAME, @ComputerName, $USR_PASSWORD, 0, $PKG_FILENAME & ' /silentswitches', '', @SW_HIDE) EndIf FileDelete($PKG_FILENAME) The script compiles right and I can create the .exe file, however when I logon with a user that does not have admin rights and run the compiled .exe it does not use the local adminstrator/password provided by the code to run the install and since the user is not administrator it prompts me for a user and a password. Could someone help to find out what am I doing wrong? Thank you! Link to comment Share on other sites More sharing options...
saywell Posted December 13, 2010 Share Posted December 13, 2010 Hi, I have found the following script which will install the .exe file with a different set of credentials in case that the current user does not have admin rights. In my case the crendentials have to be the local administrator user/passowrd which have been entered in the code below. #NoTrayIcon#RequireAdmin$USR_USERNAME = 'Administrator'$USR_PASSWORD = 'Password'$PKG_FILENAME = @TempDir & '\Package.exe'FileInstall('Package.exe', $PKG_FILENAME)If IsAdmin() ThenRunWait($PKG_FILENAME & ' /silentswitches', '', @SW_HIDE)ElseRunAsWait($USR_USERNAME, @ComputerName, $USR_PASSWORD, 0, $PKG_FILENAME & ' /silentswitches', '', @SW_HIDE)EndIfFileDelete($PKG_FILENAME)The script compiles right and I can create the .exe file, however when I logon with a user that does not have admin rights and run the compiled .exe it does not use the local adminstrator/password provided by the code to run the install and since the user is not administrator it prompts me for a user and a password. Could someone help to find out what am I doing wrong? Thank you!Is the Domain correct?William Link to comment Share on other sites More sharing options...
Messi Posted December 13, 2010 Author Share Posted December 13, 2010 Hi, The laptops are standalone. There is no domain. The .exe has to run with the local administrator user/password which is provided in the script. Thank you Link to comment Share on other sites More sharing options...
Developers Jos Posted December 13, 2010 Developers Share Posted December 13, 2010 (edited) By specifying #RequireAdmin, you basically tell the Program to prompt for the Admin password when started with a none-admin level account. Edited December 13, 2010 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...
Messi Posted December 13, 2010 Author Share Posted December 13, 2010 Could someone then tell me how should I modify the script so that basically will check to see if the logged in user is an Administrator and install the software using their credentials if true or it will attempt to use the local administrator username and password that is provided in the script. Thank you Link to comment Share on other sites More sharing options...
Developers Jos Posted December 13, 2010 Developers Share Posted December 13, 2010 So, did you try removing the #RequireAdmin line? 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...
sleepydvdr Posted December 13, 2010 Share Posted December 13, 2010 I believe that you are getting prompted for credentials to run your AutoIt created executable. I tried your script with an installer of mine and once ran the AutoIt .exe as an administrator, it ran just fine. I do not know how to bypass running it as an administrator except for maybe using a batch script: http://www.experts-exchange.com/Operating_Systems/WinXP/Q_20906129.html Perhaps you could use an AutoIt command such as ShellExecute to run an .exe as such. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
rscl Posted June 21, 2011 Share Posted June 21, 2011 Hi, Did the OP find a solution to this problem ?? I am facing the same issue. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <Array.au3> #include <EventLog.au3> <snip> RunAsWait ($sUserName, @ComputerName, $sPassword, 0,'netsh inter ip set address "Local Area Connection" source=static addr="' & $IP & '" "' & $subnet_mask & '" gateway="192.168.1.2" 1', @SystemDir, @SW_HIDE) <snip> If I right click and execute the .exe with RunAsAdmin option, it works fine, but not otherwise. I believe the script is expected to run as admin with admin credentials which is not happening. Looking for some help here... Thank you. Regards, Sans 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