Jump to content

RunAsWAit question


Messi
 Share

Recommended Posts

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

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

Link to comment
Share on other sites

  • Developers

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

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

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

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

  • 6 months later...

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...