Jump to content
Sign in to follow this  
Syed23

Help needed on ShellExecuteWait() or RunWait() functions?

Recommended Posts

Syed23

Hi Everyone Greeting,

I have been creating a tool which will install the applications automatically. Here i have a difficulty which means, the applications where customized with Shell scripting(EXE) and Admin Studio(MSI). so when i start installing the application which created with Shell Script i could able to stop the install by checking the process name of that particular executable but if i install the application which created with Admin studio the process run as msiexec.exe so i couldn't check for the process since there were 3 msiexec running during installation. Please suggest me how can we do this :oops:


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
Spiff59

I'm sure someone will suggest a better way, but you might call ProcessList() before and after each ShellExecute(), Find the msiexec.exe addition each time and maintain a list of PID's and program names. You could then exert individual control over each process.

Edit: This assumes you're manually kicking off one instance of msiexec at a time, and can therefore "keep inventory". If one call to your installer package generates all three msiexec processes, then I'm at a loss how one would externally determine the identity of each process.

Edited by Spiff59

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, Syed. If you use the following it will wait until the MSI has completed before moving on to the next line of your script:

ShellExecuteWait("msiexec.exe", '/i "' & @ScriptDir & '<MSI name>.msi" /qn')

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Syed23

Hi, Syed. If you use the following it will wait until the MSI has completed before moving on to the next line of your script:

ShellExecuteWait("msiexec.exe", '/i "' & @ScriptDir & '.msi" /qn')

This works awesome and as i expected! when i use the above one the application get installs successfully but it returns the value 0. is there any specific reason ?


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
BrewManNH

ShellExecuteWait returns the exitcode of the program you run, usually if a program completes ok, it returns 0 in the exitcode. ShellExecute on the other hand returns 1 if successful, but that's because it doesn't wait until the program finishes before continuing, and it has no way to retrieve the ExitCode.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, Syed. Chek out this link. It shows you all of the exit codes you can expect when using the Windows Installer engine. As BrewManNH noted, for an MSI the exit code of 0 is a good thing :oops:


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Syed23

Nice one guys! Thanks for the help! JLogan3o13 will this error codes will be captured by the macro @error ?


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
BrewManNH

JLogan3o13, nice find on that link, definitely going into the bookmarks.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
JLogan3o13

Nice one guys! Thanks for the help! JLogan3o13 will this error codes will be captured by the macro @error ?

I would suggest, rather than relying on @error, to pull the information you want from the event viewer. Something like this would work well for an installation of Notepad++, for example.

#include <GUIConstantsEx.au3>
#include <EventLog.au3>
Local $log, $aEvent

ShellExecuteWait("msiexec.exe", '/i "' & @ScriptDir & 'Notepad++.msi" /qb')

    $log = _EventLog__Open("", "Application")
    $aEvent = _EventLog__Read($log, True, False) ; read last event
  For $i = 1 To 10
   If $aEvent[10] <> "MsiInstaller" Then
    $aEvent = _EventLog__Read($log, True, False) ; read last event
   Else
    MsgBox(0, "Installation Results", $aEvent[13])
    _EventLog__Close($log)
    Exit
   EndIf
  Next

JLogan3o13, nice find on that link, definitely going into the bookmarks.

Glad it was helpful. The parent site where I got that link, www.AppDeploy.com is a great resource. It maintains a huge database of applications; how they can be repackaged/delivered, install and uninstall switches, reg keys, etc. It is the homepage for all of my repackagers :oops:

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Syed23

Hi, Syed. If you use the following it will wait until the MSI has completed before moving on to the next line of your script:

ShellExecuteWait("msiexec.exe", '/i "' & @ScriptDir & '<MSI name>.msi" /qn')

All your suggestion helped me lot! i have one more doubt? i have created a tool which will uninstall the application by retriving the details from Registry. Like "Msiexec.exe /X "PRoduct Key" . i don't how to use Shell Executewait to handle! will the below will work?

ShellExecuteWait("msiexec.exe", '/x "' & "" & 'product code" REBOOT=ReallySuppress /qb!')
Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, Syed. Very close :oops: It should be something like this.

ShellExecuteWait("msiexec.exe", '/x "<productID>" REBOOT=ReallySupress /qb')

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Syed23

Hi, Syed. Very close :oops: It should be something like this.

ShellExecuteWait("msiexec.exe", '/x "<productID>" REBOOT=ReallySupress /qb')

Thanks a lot JLogan3o13. i will try this for sure :bye:

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

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  

×