Jump to content

Application install script with command line options help


saldous
 Share

Recommended Posts

Hi, I'm after some help in writing a utility to do the following:

1) Display a message box asking a user to input their email address and a password.

2) Take this input from the user and pass it to the command line to install an application like this:

msiexec /i program.msi EMAILADDRESS=UserInput1 PASSWORD=UserInput2

How do I do this? It sounds simple but I'm completely stuck and I'm new to AutoIT so I would appreciate any help from all you experienced scripters out there.

Thanks in advance.

Link to comment
Share on other sites

GUICreate("Enter EMail/Password :",250,90)
GUICtrlCreateLabel ("Email:",10, 10,60,21)
$E=GUICtrlCreateEdit ("",  70, 6,175,19)
GUICtrlCreateLabel ("Password:", 10, 36,60,21)
$P=GUICtrlCreateEdit ("", 70,32,175,21)
$K=GUICtrlCreateButton("OK",100,60,50)
GUISetState(@SW_Show)

While 1
   $msg = GUIGetMsg()
   Select
    Case $msg=-3 
      ExitLoop
    Case $msg=$K
      Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($E) & "PASSWORD=" & GUICtrlRead($P))
    EndSelect
WEnd

Link to comment
Share on other sites

Wow, thanks, I'd been working on something for ages trying to figure this out and you made it so simple!

However I've got a few more questions:

1) I want to be able to stop the user leaving either of the fields blank, i.e they must enter something. I can do this using the InputBox command (by putting in " M", but can't work out how to do it using GUICtrlCreateEdit. Any ideas?

2) On the password field, I want the password to be displayed as "*" instead of the actual password, I've tried adding in the $ES_PASSWORD command but it errors out when converting the script to an EXE

3) A nice to have: I would like to put in a pasword verification, make the user type it in again and then check it is the same as the one previously entered, if it isn't correct the "OK" button should give an error until the passwords match.

4) Also, how do I make the text input box only one line stopping the user pressing enter generating more lines and the scroll bars?

This is as far as I had got myself:

CODE
;Install Script v0.8

;User enters email address

$email = InputBox("My Application Install Package:", "Enter your email address", "", " M", _

400, -1)

;User enters password

$passwd = InputBox("Application Install is 25% complete", "Choose a password to protect your account.", "", "*M8", _

400, -1)

;Install Application using user input fields

Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($email) & "PASSWORD=" & GUICtrlRead($passwd))

Thanks for your help once again.

Edited by saldous
Link to comment
Share on other sites

ok, I'm getting closer, I've got the password verification working, last thing to do is to get the cancel button to exit the application:

CODE
; Install Script v0.8

; User enters email address

$email = InputBox("Application Install Package", "Enter your email address", "", " M", _

400, -1)

; Start loop to ensure user enters the same password twice

$bLoop = 1

While $bLoop = 1

; User enters password

$passwd = InputBox("Application Install Package 25% complete", "Choose a password to protect your account.", "", "*M8", _

400, -1)

; 2nd password box to check it matches the first

$passwd2 = InputBox("Application Install Package", "Please re-type your password for verification", "", "*M8", _

400, -1)

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - Please try again!")

Else

; They clicked OK, but did they type the right thing?

If $passwd2 <> $passwd Then

MsgBox(4096, "Error", "Your passwords do not match - please try again!")

Else

$bLoop = 0

EndIf

EndIf

WEnd

; Prompt the user to install or not - use a Yes/No prompt

$answer = MsgBox(4, "Start Installation", "Click on YES to start the install")

; Check the user's answer to the prompt

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

If $answer = 7 Then

MsgBox(4096, "", "Install cancelled.")

Exit

EndIf

;Install Application using user enter parameters

Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($email) & "PASSWORD=" & GUICtrlRead($passwd))

; Finished!

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