Jump to content

Installing exe without admin rights


Recommended Posts

Hi everyone,

I have a product exe that I need to install, and incorporate admin credentials to install it on user's machines that do not have admin rights. This is the script:-

====================================

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "Juniper SSL Insaller", "This file will allow you to remotely access the network but will require a reboot once completed, run now?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "Juniper SSL Insaller", "You have chosen not to install at this time, installer will now exit.")

Exit

EndIf

RunAsWait("Administrator", "@XPTEST", "Password", 2, "JuniperSetupServiceInstaller.exe")

Sleep(10000)

Send("{ENTER}")

==================================

The script runs but it never uses the admin rights I have specified so does not install, has anyone got any ideas where I am going wrong?

Cheers

Link to comment
Share on other sites

A couple of things:

1. logon_flags 2 = Network credentials only.

2. No full path to executable.

3. No working directory provided.

4. Phenomenally bad idea to hard code the admin password into a script; it is not secure.

muttley

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

A couple of things:

1. logon_flags 2 = Network credentials only.

2. No full path to executable.

3. No working directory provided.

4. Phenomenally bad idea to hard code the admin password into a script; it is not secure.

muttley

===============================================

Hi Psalty,

Cheers fory our response. A couple of questions, i'm new to this scripting malarky! Looking at the help file:-

----------------------------------

Parameters

username - The username to log on with.

domain - The domain to authenticate against.

password - The password for the user.

logon_flags

0 - Interactive logon with no profile.

1 - Interactive logon with profile.

2 - Network credentials only.

4 - Inherit the calling processes environment instead of the user's.

filename - The name of the executable (EXE, BAT, COM, or PIF) to run.

workingdir - [optional] The working directory. If not specified, then the value of @SystemDir will be used.

flag [optional] - The "show" flag of the executed program:

@SW_HIDE = Hidden window (or Default keyword)

@SW_MINIMIZE = Minimized window

@SW_MAXIMIZE = Maximized window

standard_i/o_flag [optional] Provide a meaningful handle to one or more STD I/O streams of the child process.

1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream

2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream

4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream

8 ($STDERR_MERGED) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD.

----------------------------------

If I copy the script and exe to the C: drive (system directory), this should run without me needing to provide the working directory?

The exe is run in the same location as the exe, so I shouldn't need to put in a path for the executable, is this correct?

So true about the admin rights, but this is a current necessity so am willing to take the risk!

In regards to my RunAs line, how would you write it based on the above information?

Cheers

Link to comment
Share on other sites

===============================================

Hi Psalty,

Cheers fory our response. A couple of questions, i'm new to this scripting malarky! Looking at the help file:-

----------------------------------

Parameters

username - The username to log on with.

domain - The domain to authenticate against.

password - The password for the user.

logon_flags

0 - Interactive logon with no profile.

1 - Interactive logon with profile.

2 - Network credentials only.

4 - Inherit the calling processes environment instead of the user's.

filename - The name of the executable (EXE, BAT, COM, or PIF) to run.

workingdir - [optional] The working directory. If not specified, then the value of @SystemDir will be used.

flag [optional] - The "show" flag of the executed program:

@SW_HIDE = Hidden window (or Default keyword)

@SW_MINIMIZE = Minimized window

@SW_MAXIMIZE = Maximized window

standard_i/o_flag [optional] Provide a meaningful handle to one or more STD I/O streams of the child process.

1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream

2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream

4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream

8 ($STDERR_MERGED) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD.

----------------------------------

If I copy the script and exe to the C: drive (system directory), this should run without me needing to provide the working directory?

The exe is run in the same location as the exe, so I shouldn't need to put in a path for the executable, is this correct?

So true about the admin rights, but this is a current necessity so am willing to take the risk!

In regards to my RunAs line, how would you write it based on the above information?

Cheers

Experiment with various values for $iLogonFlag:
#include <String.au3>

; ...

$sUserName = "Administrator"
$sDomain = "@XPTEST"
; Still not very secure, but at least not saved as plain text:
$sPassword = _StringEncrypt(0, "EEC813BD20978A9F34C151AAB2031108", "!2#4%6&8(0_1@3$5^7*9)-") 
$iLogonFlag = 0
$sExeDir = @ScriptDir
$sExeFile = "JuniperSetupServiceInstaller.exe"
$sExePath = $sExeDir & "\" & $sExeFile

RunAsWait($sUserName, $sDomain, $sPassword, $iLogonFlag, $sExePath, $sExeDir)

muttley

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Experiment with various values for $iLogonFlag:

#include <String.au3>

; ...

$sUserName = "Administrator"
$sDomain = "@XPTEST"
; Still not very secure, but at least not saved as plain text:
$sPassword = _StringEncrypt(0, "EEC813BD20978A9F34C151AAB2031108", "!2#4%6&8(0_1@3$5^7*9)-") 
$iLogonFlag = 0
$sExeDir = @ScriptDir
$sExeFile = "JuniperSetupServiceInstaller.exe"
$sExePath = $sExeDir & "\" & $sExeFile

RunAsWait($sUserName, $sDomain, $sPassword, $iLogonFlag, $sExePath, $sExeDir)

muttley

=========================================

I will get on with that and let you know how I get on, cheers for your help on this!

Just one other question, do you need to supply the domain name/computer name? This script will be sent to users who are not connected to the network, and will therefore be logged on locally or with cached domain credentials. I would have to replicate this script hundreds of times to accommodate the amount of machine names that will be out there. Any variable I could put in to capture the computer name when executed?

Link to comment
Share on other sites

Just one other question, do you need to supply the domain name/computer name? This script will be sent to users who are not connected to the network, and will therefore be logged on locally or with cached domain credentials. I would have to replicate this script hundreds of times to accommodate the amount of machine names that will be out there. Any variable I could put in to capture the computer name when executed?

$sDomain = @ComputerName

muttley

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...