I have used this script many times now in many different versions and I thought it was time to share an example on what can be achieved with a vbscript. It can be used to display information to the user and let the used postpone the Installation/Upgrade a number of times, check for running processes and more.
The following features exist in this example and can be seen as an example on what can be done, so adjust it to fill your needs. A HTA to display more information is one example of an enhancement, adding more processes to check another.
The script is run using the “Run this program before” feature and can be used both for Programs and for Task Sequences.
Functions:
- Prompt the user that an installation/upgrade is about to be performed.
- Allow the user to postpone the installation/upgrade of an application x amount of times. If the user postpones the installation the script will return exit code 1 and SCCM will assume it failed and not continue depending program or task sequence.
- After x amount of times postponed the script will start the installation anyway.
- Countdown timer
- Check that the process specified is closed if not prompt the user to close it.
Screenshots of how it will look at the client:
If the user press Cancel:
If the Process specified is running:
Usage:
- Download the script: https://ccmexec.com/wp-content/uploads/2011/09/Prerun1.txt
- Create a Package in SCCM containing the prerun1.vbs file
- Create a Program with a command line for executing the script, for example:
“wscript.exe prerun1.vbs Excel Excel.exe” - Configure the settings under environment according to the example below.
- For the Application you want to use it to install configure it to run the Prerun1 program before like this:
- Then advertise it as you normally would and try it out!
I hope this can has showed a new example of what can be done using Configuration Manager and a little bit of scripting.
Hey ,
I did similar thing , but I have written it in VS 2010. Basically user can install immediately or press postpone. It displays 60 min and counting down timer. When user postpone it minimize to tray and then pop up automatically 5 minutes before deadline.
I have a friend going through this, I email him. Thanks for posting this!
Great work thank you. I have come across a problem however, It works fine with just one application string i.e. word winword.exe but if you use multiples i.e. word excel outlook winword.exe excel.exe outlook.exe it just exits and I can’t see why. This is important as otherwise the user will get prompted each time you run the check for each single application. I see you allow up to 5 processes to be examined. Any feedback to resolve this would be greatly appreciated.
Hi, this is brilliant, but i have tried it in my test enviroment, and if i click Cancel 3 times, it just report FAILED in the sccm logs, and the application do not install…
I have i the advertisemenr the following schedule:
Run as soon as possible
Occurs on 26.10.2011 12:00
Occurs on 26.10.2011 12:15
@ Wayner Resetto: I will post an update with support for more command-lines than one.
@Stian: Which advertisement failed? the script or the depending application?
/Jörgen
Hi Jörgen,
I am having an issue getting a VB script to work in either the run program before option or in a TS. I have tried your method listed above and tried some methods using serviceui.exe. I am not sure if its my script/hta or I am missing a step. I am trying to do a sql 2008 mgmt studio deployment and need to deploy windows framework/powershell and windows installer first. After these 2 install, I need to prompt the user that they need to save their work and hit ok to restart. If I run the script in a program by itself it works, but not when I If you have time I can send you the script and more details on how I set up the TS and programs.
Thanks!
Hi,
I’ve tried using your program because it is an addition to the SCCM toolkit that I want to use to allow users a bit more flexibility in installing programs and making sure that processes aren’t running that might block the install. I’ve tested to make sure the script works on it’s own without any errors. When I setup the Check Excel program the way shown, I can not choose to use in a task sequence as it’s own program, which I believe is because of the setting to “Allow users interaction with the program”. So, I believe as shown, the only way to use this is with an Advertised Program, not an Advertised Task Sequence.
I’m getting a SCCM error (80008013 which indicates the task to run before may/may not have been successful, SCCM can’t tell) when I try to use it as a task to run before the install (as shown above). I am testing pushing out an application install using a Task Sequence and the prompt does not come up as shown. I was hoping to use a Task Sequence to test with this because I usually use Task Sequences to install software because of customizations and because it shows a progress bar to the user. As far as I am aware, if the checkbox “Allow users to interact with this program” is checked for Check Excel, then this Package/Program is not available to be used in a Task Sequence.
Thanks for any help you may give here…
Chris
Hi Jörgen,
I hope you don’t mind me shamelessly plugging the Powershell App Deployment Toolkit here, because I think anyone who is interested in the functionality your script provides will want to check it out. It does everything your script can do plus a whole lot more with lots of configurable options to prompt users to close apps, prevent apps from being launched during install, defer X number of times, x number of days or until deadline is reached, countdown to automatic closing of apps, etc. It plays nicely with SCCM and makes use of fast retry codes for deferrals. Also, it has a nice UI that can be branded with a corporate logo/banner, the text is customizable in XML and is localised in several languages.
You can download the tool here: http://psappdeploytoolkit.codeplex.com
Thanks, Seán
Is there a way to have it check for a process other than the one that is being installed and to correctly prompt the user? For example, what if I’m installing Flash and I need to see if Internet Explorer is running. If I configure the command like “wscript.exe prerun1.vbs Flash iexplore.exe” It’s going to tell the user Flash is being upgraded and then if IE is open, it’s going to tell it to close Flash, which is incorrect. If you change it to “wscript.exe prerun1.vbs Internet Explorer iexplore.exe” it’s going to tell the user Internet Explorer is being upgraded, which is also incorrect. What it needs to do is Say Flash is being upgraded, give the user the option to say OK or postpone and then if Internet Explorer is open it detects it and then tells the user they need to close Internet Explorer. Hopefully that makes sense.
Is it possible to use it in a task Sequence??
Hi,
Yes, you can use it in a task sequence with the use of ServiceUI.exe or as a pre-run command to the task sequence.
/Jörgen