Sunday, February 27, 2011 4:57 PM
VBScript to Eject WinPE Discs
In our SCCM environment our network topology doesn't easily lend itself to using PXE when imaging our machines. Thus we rely on SCCM OS Image Installation discs (or USB keys) to boot our machines and initiate the OS imaging process. After having several machines accidentally go out the door to customers with this disc still in the drive, we decided that we needed a way to eject it if it was still inserted once the imaging process started.
EjectWinPE.vbs (right-click and save the linked file)
(you will need to save the file and then change the .TXT extension to .VBS)
- Save the "EjectWinPE.vbs" VBScript and the .EXE utility to a folder on your machine.
- Make sure you right-click the files, selecting Properties, and then Unblock it if the option is shown.
- You may use Notepad if you wish to edit the script.
- Test things to make sure the script will work in your environment:
- Simply insert your SCCM OS Image Installation disc, and once it has finished spinning up and doing its thing, execute the VBScript. It should detect and eject the inserted disc.
- This script was built to eject MDT integrated discs, so you may need to adjust Line 21 in the .VBS file to look for an existing file on your own disc.
- While you can have this script executed a variety of ways due to the power and flexibility of SCCM and task sequences, one quick and easy method is listed here. In our environment we chose this route because we were already mapping to a server to perform other tasks, so it was a simple solution for us.
- Place the files in a folder on a server where you will map a network drive during the imaging process.
- Edit your OS task sequence to add an item to connect to the server where your VBScript resides:
- Edit your OS task sequence to add an item to execute the VBScript using the recently mapped network drive:
- That should be it. Your OS task sequence should now attempt to eject the SCCM OS Image Installation disc if it is still inserted after the task sequence begins to run.
NOTE 1: If you use Notepad to edit a VBScript, make sure you disable Word Wrap (Format | Word Wrap) as it makes things easier to read.
NOTE 2: If using Notepad, once you disable Word Wrap you can display line numbers by selecting the View | Status Bar menu item. The line number that the cursor is on will now display in the lower right corner of the window.
Filed under: Scripts, VBScript