Jump to content

A Check if msiexec.exe is running before running install script


Beekman
 Share

Recommended Posts

Hello,

Can anybody help me. I am very new at this.

We have a situation that our company is using two distribution channels.

Wintel group is using SCCM and we are using Autoit scripts.

Because Msiexec.exe only can runnig ones on a computer our installations are getting interrupted.

So therefore I want to put a check in the autoit script that checks if the msiexec.exe is runing and if it is running then wait until this process is done or stopt and then starts our installation.

Our script :

$cmd1 = 'c:\temp\mcupgrade\install\setup /s /v"/qb-"'
$cmd2 = 'c:\temp\mcupgrade\elevate c:\temp\mcupgrade\fixpack\setup /s /v"/qb+"'

Local $size1 = FileGetSize("c:\temp\mcupgrade\install\setup.exe")
Local $size2 = FileGetSize("c:\temp\mcupgrade\fixpack\setup.exe")

If $size1 = 173408 And $size2 = 7219000 Then

Local $pid = RunAsWait("administrator account",<password>,"",'"' & @ComSpec & '" /c ' & $CMD1, @SystemDir)
ProcessWaitClose($pid)
RunAsWait("administrator account",<password>,"",'"' & @ComSpec & '" /c ' & $CMD2, @SystemDir)

EndIf
Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

Beekman,

Welcome to the AutoIt forum. :)

ProcessExists would seem to be the answer to your problem: ;)

While 1
    ; If the process is not running
    If Not ProcessExists("msiexec.exe") 
        ; Break out of the loop
        ExitLoop
    EndIf
    ; Wait a second
    Sleep(1000)
WEnd
; We get here if msiexec is not running

All clear? :)

M23

Edit: When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hello Melba23,

Many thanks for the quick response.

But I have still 2 question.

1. You do a check if the process not exists, but what happens in this script if the process exists?

Is this going to wait until the process stops?

2. Is there a possiblility to suppress the UAC from Windows 7 with a autoit command or parameter?

Edited by Beekman
Link to comment
Share on other sites

  • Moderators

Beekman,

1. You stay in the While...WEnd loop if the process exists - that is why we have the Sleep in there so you do not check too often. :)

2. Adding #RequireAdmin to your script will force admin credentials to be entered at the start of the script. You will understand that simply suppressing UAC from a script is not something that can (or indeed should) be done. Search the forum and you will find plenty of tips on how to make UAC as inobtrusive as possible. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

As the msiexec process can continue within Task Manager after an installation is run (even if it is not chewing up any CPU), and you mention you have SCCM in the environment, I would suggest a different method. I would check on the CPU usage of the CCMExec process to determine whether SCCM is installing anything. Something like this should work:

$wbemFlagReturnImmediately = "&h10"
$wbemFlagForwardOnly = "&h20"
$PC = "PCName"

$WMI = ObjGet("winmgmts:\\" & $PC & "\root\CIMV2")
$aProcess = $WMI.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

 For $element in $aProcess
  If $element.Name = "CCMExec" Then MsgBox(0, $element.Name, $element.PercentProcessorTime & "%")
 Next

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

Beekman,

As you have it, but without the trailing "." after Exit. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

As the msiexec process can continue within Task Manager after an installation is run (even if it is not chewing up any CPU)

It will continue for approximately 10 minutes. I ran into this problem with msiexec staying resident in my installer script. The problem is that if you use RunWait on something that launches the msiexec as a child, then exits, if you don't wait for msiexec to exit normally and reboot, the installation can fail. The Infineon TPM installer is one example of this problem. You can find some details of this if interested:

http://www.msfn.org/board/topic/151373-msiexec-taking-a-long-time-to-complete/page__view__findpost__p__971399

Link to comment
Share on other sites

  • Moderators

It will continue for approximately 10 minutes. I ran into this problem with msiexec staying resident in my installer script. The problem is that if you use RunWait on something that launches the msiexec as a child, then exits, if you don't wait for msiexec to exit normally and reboot, the installation can fail. The Infineon TPM installer is one example of this problem. You can find some details of this if interested:

http://www.msfn.org/board/topic/151373-msiexec-taking-a-long-time-to-complete/page__view__findpost__p__971399

That is why, as the OP is using SCCM, I suggested looking at the CCMExec process, rather than msiexec.

Edit: spell check :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I believe there will be two msiexec.exe processes. One that is the installation (msiexec.exe) in the users context and one that is the installer service (msiexec.exe) in the SYSTEM context. Also, I believe there may be a registry key that is set while the install is running. That key is cleared by the installer when it is finished. I used to use it, I will try to dig it up.

Lar.

edit: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionInstallerInProgress

Edited by LarryDalooza

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

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