Jump to content

Deploying with SCCM, need to run an MSI after doing some cleanup


Recommended Posts

We are preparing to deploy mimecast to our end users within our company, however the MSI installer requires that the user be out of Outlook first. What I'd like to do is use AutoIT to handle prompting the user to close their work, kill outlook, and then go ahead with the MSI installation under /q with a nice splash screen to keep their attention while it runs. It will get distributed to the company via SCCM.

Here's what I have so far...

;the following two lines are not in use...;$sUserName = 'administrator'
;$sPassword = 'password for the local admin account'


$sDomain = @ComputerName
$pathToMSI = @WorkingDir & "\MimecastServicesforOutlook4.1.465.5462_32_bit.msi"


MsgBox(0,"test","Installing Mimecast",10)


SplashTextOn("Please wait...","Checking if outlook is still open...",400,200)
While ProcessExists("outlook.exe")
ProcessClose("outlook.exe")
Sleep(50)
WEnd
SplashOff()


SplashTextOn("Please wait...","Installing Mimecast. Please wait.",400,200)


;not sure if the following line is needed...
;RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE)


$file = ShellExecuteWait('msiexec', "/i " & $pathToMSI & " /q")


If $file = 0 Then
ConsoleWrite("Failed to install Mimecast"& @CRLF)
EndIf


SplashOff()


MsgBox(0,"Installation Complete","Mimecast has been installed on your computer.")

Right now, the script itself seems to run fine, I get all the pop up boxes. I don't think that the msi installer is running though, any ideas on what I can change to fix this?

Link to comment
Share on other sites

  • Developers

Is the script ran with the Users credentials or through a service using the SYSTEM credentials?

Is the workdir a Server UNC, Server Mapped drive or the local harddisk?

You probably need double quotes around the MSI path&file:

$file = ShellExecuteWait('msiexec', '/i "' & $pathToMSI & '" /q')

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Question was how you are running the script, not how to do something different. ;)

So have you tried the proposed change and an answer how you run the script?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the slow response, I couldn't answer the question originally because I didn't know how SCCM handled things. It looks like SCCM executes files based on the SYSTEM account. There is an option that lets you allow user interaction with the files being executed by SCCM however that I have successfully tested in the past (just not with MSIs). Everything is being run locally from C:Windowsccmcache(some randomly assigned folder)

I have also applied the double quotes suggestion.

So far the process is still erroring out, so I don't think its working correctly.

Link to comment
Share on other sites

  • Moderators

Sorry for the slow response, I couldn't answer the question originally because I didn't know how SCCM handled things. It looks like SCCM executes files based on the SYSTEM account. There is an option that lets you allow user interaction with the files being executed by SCCM however that I have successfully tested in the past (just not with MSIs). Everything is being run locally from C:Windowsccmcache(some randomly assigned folder)

I have also applied the double quotes suggestion.

So far the process is still erroring out, so I don't think its working correctly.

 

Which version of SCCM are you using? Both 2007 and 2012 allow you to choose the credentials you run the package under. It also allows you, right from SCCM to set up a staged install, in which you could have SCCM close any open applications (Outlook in this case), and then begin the installation. You can even set it up so the user receives a pop up message.

"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

Sccm with a one/two line batch can do all this you're asking for - really no need to use AutoIt. :)

write a batch/powershell/vbscript to kill the process and use the /qb-! parameter in your MSI installation. (Displays a basic user interface without cancel button)

i.e install.bat:

start /wait /min TASKKILL /IM outlook.exe /T /F

msiexec /i "MimecastServicesforOutlook4.1.465.5462_32_bit.msi" /qb-!

this should terminate outlook.exe and start the msiexec service, assuming the names are correct. Save as install.bat and make set as install path on sccm.

Remember to make sure the account you're using for the installation has rights for the ccmcache folder. If they don't, you should copy it to a folder of your choosing, where they have rights. Ells the installation obviously won't work :)

If you do wanna go the autoit way, sorry for wasting your time :P

Edited by Joeit
Link to comment
Share on other sites

Why are you using ShellExecuteWait instead of RunWait? For example:

$file = RunWait('msiexec /i "' & $pathToMSI & '" /q')

I think this will be a better solution for this particular purpose.

 

How does using RunWait work better compared to ShellExecuteWait? Does RunWait run the command under the account that is running the autoit exe?

Which version of SCCM are you using? Both 2007 and 2012 allow you to choose the credentials you run the package under. It also allows you, right from SCCM to set up a staged install, in which you could have SCCM close any open applications (Outlook in this case), and then begin the installation. You can even set it up so the user receives a pop up message.

 

SCCM 2012, we are working on the SP1 upgrade but its still a little ways out. Are you talking about using a task sequence? How do you do the pop up messages?

Link to comment
Share on other sites

  • Moderators

There are a lot of different ways to do it. I would spend some time Googling to find the way that suits you best. My preference is using AutoIt to run the job, specifying the credentials, of course. But you can also do a task sequence, with an AutoIt script just to send the pop up message. There are also a couple of articles out on MSDN for creating a custom hta within SCCM that you can run as part of your install.

"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've been digging around for awhile on this one actually to find the way that best suits me. Thats how I ended up thinking I'd go this route for this app.

How are you specifying credentials for the autoit app being run? Originally I wanted this to all just run through one autoit script to make things really simple. I was under the impression that running msiexec on the installer was going to cause problems because of the way SCCM executes things. Is there a best way to run msiexec using autoit deployed by SCCM that you know of?

This has been driving me crazy for weeks  :sweating:

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