Jump to content

Running Silent Install via RunAsSet


Recommended Posts

What I'm trying to do, is run a silent installation with the RunAsSet() function for users who are non-Admins.

For the the non-Admin users, I'm copying the necessary folder & files and running the setup.exe as a Local Admin - thanks to RunAsSet.

I have no trouble running the same basic script when a user has Admin rights, (without RunAsSet) and without copying any files.

The below script seems to work until almost the very end of installation and then dies out without completion.

I receive no errors, yet it doesn't work.

Is there a known problem running a silent install with the RunAsSet() function? Am I missing something, somewhere?

Thank you for any help...

FileCopy("I:\Software Updates\UXT 3.01\Client\*.*", "C:\UXT301\")
If @Error Then
  MsgBox(4096, "Copy Status", "Error copying " & @error, 10)
Endif

RunAsSet("Administrator", @Computername, "$password",  2)
If @Error Then
  MsgBox(64, "UXT 3.01 Upgrade", "Error running RunAsSet.", 10)
Endif

If FileExists("C:\UXT301\Setup.exe") Then

  RunWait("C:\UXT301\Setup.exe /s", "C:\UXT301")
  
Else
  MsgBox(64, "UXT 3.01 Upgrade", "Setup.exe cannot be located.", 10)
Endif
RunAsSet()
Link to comment
Share on other sites

What I'm trying to do, is run a silent installation with the RunAsSet() function for users who are non-Admins.

For the the non-Admin users, I'm copying the necessary folder & files and running the setup.exe as a Local Admin - thanks to RunAsSet.

I have no trouble running the same basic script when a user has Admin rights, (without RunAsSet) and without copying any files.

The below script seems to work until almost the very end of installation and then dies out without completion.

I receive no errors, yet it doesn't work.

Is there a known problem running a silent install with the RunAsSet() function? Am I missing something, somewhere?

Thank you for any help...

FileCopy("I:\Software Updates\UXT 3.01\Client\*.*", "C:\UXT301\")
If @Error Then
  MsgBox(4096, "Copy Status", "Error copying " & @error, 10)
Endif

RunAsSet("Administrator", @Computername, "$password",  2)
If @Error Then
  MsgBox(64, "UXT 3.01 Upgrade", "Error running RunAsSet.", 10)
Endif

If FileExists("C:\UXT301\Setup.exe") Then

  RunWait("C:\UXT301\Setup.exe /s", "C:\UXT301")
  
Else
  MsgBox(64, "UXT 3.01 Upgrade", "Setup.exe cannot be located.", 10)
Endif
RunAsSet()
one thing that's going to mess you up is you're sending "$password" as the password. if you want to send the value stored in $password, remove the quotes. otherwise you're sending the literal string $password which is most likely not the password....
Link to comment
Share on other sites

I apologize, I added the "$password" in the posting to keep the actual password secure. The password I used in the code is a non-variable in quotes. Again, I'm very sorry for the mistake. I should have written, "password" as the parameter used. As I said, I've rec'd no error messages and the script almost completes, but not quite. I've tried different ways of fine tuning the script, but this at least runs without an error. I've found that the installation apparently registers some dll files. Shouldn't the RunAsSet function - (as local Admin) compensate and let the installation register the files as the local Admin? I realize that the RunAsSet function only works for Run and RunWait. Would this be tripping up the last bit of the install? If so, is there a workaround?

Link to comment
Share on other sites

I apologize, I added the "$password" in the posting to keep the actual password secure. The password I used in the code is a non-variable in quotes. Again, I'm very sorry for the mistake. I should have written, "password" as the parameter used. As I said, I've rec'd no error messages and the script almost completes, but not quite. I've tried different ways of fine tuning the script, but this at least runs without an error. I've found that the installation apparently registers some dll files. Shouldn't the RunAsSet function - (as local Admin) compensate and let the installation register the files as the local Admin? I realize that the RunAsSet function only works for Run and RunWait. Would this be tripping up the last bit of the install? If so, is there a workaround?

If the installer makes use of the dll's, and the installer is run as administrator, then there should be no issue with permissions. it sounds to me like the RunAsSet is failing. one way to test i think, would be to make a script like:

MsgBox(0,"Username",@UserName)

compile that to an exe and execute that from your script after the runasset() that way if the RunAsSet() worked, it should return the administrator login, not the current one....

Link to comment
Share on other sites

You may want to check to see if the program has any switches on the setup.exe file. Try /s, /silent, /q to name a few. You can make your scripts much simpler, and in many cases hide them from the user simply by using the switches. CHeck the readme in software you have to see if the program supports command line switches.

Here is a example of installing Ad-Aware with 4 lines of code. The user will not see anything during the install:

RunAsSet ("Administrator", "Domain", "password")
runwait("aawsepro.exe /s", "C:\bin\adaware")
RunAsSet ("Administrator", "Domain", "password")
runwait("ad-aware.exe +silent +update", "C:\program files\lavasoft\ad-aware se professional" )

This installs Ad-Aware, and updates it without the user knowing anything, and the user can keep working while it is doing its thing.

enjoy!

;)

Link to comment
Share on other sites

If the installer makes use of the dll's, and the installer is run as administrator, then there should be no issue with permissions. it sounds to me like the RunAsSet is failing. one way to test i think, would be to make a script like:

CODE

MsgBox(0,"Username",@UserName)

compile that to an exe and execute that from your script after the runasset() that way if the RunAsSet() worked, it should return the administrator login, not the current one....

I did test as you suggested. The user name is displayed as the logged on user name, not as Administrator. I tested all three ways one can use RunAsSet, i.e., RunAsSet("Administrator", @Computername, "password", 0 or 1 or 2). In all three cases, I got the currently logged on user name and not the "Administrator" name. The fourth parameter, (using a 2) is the one that works without a system error message. I've also used error trapping with the if statement:

RunAsSet("Administrator", @Computername, "password",  2)
If @Error Then
  MsgBox(64, "UXT 3.01 Upgrade", "Error running RunAsSet.", 10)
Endif

It seems as though the RunAsSet function works, as I don't receive the above message in the case of a RunAsSet failure. Wouldn't the AutoIT macro - @UserName capture the logged on username as an environment variable? In that case, one would always get the logged on user name and not the RunAsSet user?

Link to comment
Share on other sites

I did test as you suggested. The user name is displayed as the logged on user name, not as Administrator. I tested all three ways one can use RunAsSet, i.e., RunAsSet("Administrator", @Computername, "password", 0 or 1 or 2). In all three cases, I got the currently logged on user name and not the "Administrator" name. The fourth parameter, (using a 2) is the one that works without a system error message. I've also used error trapping with the if statement:

RunAsSet("Administrator", @Computername, "password",  2)
If @Error Then
  MsgBox(64, "UXT 3.01 Upgrade", "Error running RunAsSet.", 10)
Endif

It seems as though the RunAsSet function works, as I don't receive the above message in the case of a RunAsSet failure. Wouldn't the AutoIT macro - @UserName capture the logged on username as an environment variable? In that case, one would always get the logged on user name and not the RunAsSet user?

if you're calling the script to report the username with a Run command after the RunAsSet() it seems like it should return the name it's being run as... one way to test that i guess would be to set permissions on your script that only allow 1 user to run it, then call your script. then regardless of what it returns, you can be 100% sure that it was run as the login you're trying use.
Link to comment
Share on other sites

  • 2 weeks later...

Lets test that:

Compile this script to c:\temp\user.exe

msgbox(0,"USERNAME", @username)

and run this script:

RunWait("c:\temp\user.exe")
RunAsSet("Administrator", @ComputerName, "password")
RunWait("c:\temp\user.exe")

then you should see 1. Message showing your Username and a 2. Message with Administrator!

An other secure way to Test:

Compile this script to c:\temp\setuser.exe

RegWrite("HKEY_CURRENT_USER","Username","REG_SZ",@UserName)

Compile this to c:\temp\getuser.exe

$username = RegRead("HKEY_CURRENT_USER","Username")
msgbox(0,"USERNAME", $username)

run c:\temp\setuser.exe !

Log on as Administrator an run c:\temp\setuser.exe again!

then logon back ( with your user account) again and run this script:

RunWait("c:\temp\getuser.exe")
RunAsSet("Administrator", @ComputerName, "password")
RunWait("c:\temp\getuser.exe")

again you should see 1. Message showing your Username and a 2. Message with Administrator!

Edited by Sigi2
Link to comment
Share on other sites

RunAsSet("Administrator", @Computername, "password", 2)
If @Error Then
  MsgBox(64, "UXT 3.01 Upgrade", "Error running RunAsSet.", 10)
Endif

It seems as though the RunAsSet function works, as I don't receive the above message in the case of a RunAsSet failure. Wouldn't the AutoIT macro - @UserName capture the logged on username as an environment variable? In that case, one would always get the logged on user name and not the RunAsSet user?

RunAsSet always succeeds on an OS that supports it. (2k, XP, 2k3)

You won't know if the credentials are good until you use Run/RunWait.

None of the variables or macros in the currently running script are affected by this function.

Follow Sigi2's examples, and check out the RunErrorsFatal option in the help file.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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...