I’ve been doing some work for a client recently to update their 3rd party applications which they have deployed using Intune. I ran into a problem whereby when updating Java, the older versions are not uninstalled/overwritten by the update, so older versions of Java are left installed on clients. I was able to remove the older versions of Java easily using a batch script on a test client, but this script needed rolling out to all clients on the domain and our customer primarily use Intune for 3rd party application management. Currently, Intune does not let administrators add batch files for deployment, as shown below.
After doing some investigating, I stumbled across something built into Windows called iexpress.exe.
This allows users to create and package their own applications. I will now demonstrate how to do this using the wizard in iexpress.
Ensure that you have your batch script in a tested and working state, so it is ready to be packaged up. It’s important that your script doesn’t require changes once the application has been packaged as you will have to make changes to the batch file and then re-package as a new, separate package. Once you are ready, search for iexpress in Windows Search, and open it. Ensure you run it with administrator privileges otherwise the wizard won’t be able to create the cabinet due to permissions.
We are going to be creating a new self extraction directive file. This is selected by default, as shown below, so you can click next.
Ensure that extract files and run an installation command is selected. This should be selected by default, so you can click next.
For the name of the package, you can call it whatever you want. I have called mine Example. Once you have completed this, click next.
Then it will ask whether you want to set a confirmation prompt or not. There is no right or wrong here as it’s personal preference. I wanted to deploy it silently so I left no prompt selected.
You will be asked to specify whether to display a licence agreement or not. This is primarily down to what you are deploying. As we are deploying a batch script to remove software, a licence agreement is not required, so I will leave do not display a license selected.
Now we need to add the files that we would like in the package. This is where we add the batch file and anything else that you wish to deploy.
Once added, we need to specify the command which will run once the package is executed on the end user device. We want our batch file to run, so I have entered the below command which will run command prompt and then run my batch file.
cmd.exe /c filethatyouwanttorun.bat
It will now ask you to specify how you want the installation to display. Because this is just a background batch script, I am going to select hidden.
We are given the option to add a finished message. As I’m doing this as a silent install, I have selected no message.
Now we need to specify where to save the package. I have chosen the desktop for this example. Ensure that you tick hide file extracting progress animation from user and also store files using long file name inside package. Don’t worry about the popup displayed as it only affects Windows 95.
Next step is to specify whether the package should reboot the machine. As it’s just a script, I have specified no.
Now we are given the choice of saving the SED file which is what stores all of our preferences that we’ve gone through above. This is handy for if you need to re-create the package at a later date with an updated version of the batch file. If you don’t think you’ll need this, select don’t save. As this is an example, I don’t need to do this.
We are now ready to create our package. Click next to create it.
As you can see below, our package has been created successfully.
You can now add this into Intune as a normal application. You won’t need to define any switches as Intune will run it silently by default for you.