Sign in to follow this  
Followers 0
Messi

RunAsWAit question

8 posts in this topic

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!

Share this post


Link to post
Share on other sites



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!

Is the Domain correct?

William

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

By specifying #RequireAdmin, you basically tell the Program to prompt for the Admin password when started with a none-admin level account.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0