Don't clean up your image (just yet)!

Hi all,

I thought I'd post a tip on this shiny new blog that we've created just to get the ball rolling!  We have high expectations for the content on this page, we now need to live up to them!  Anyway, the following is something I see in a lot of my deployment projects; and it often catches people out.

If you are creating a new WIM image that will have applications pre-installed and then captured, often you will want to 'clean up' the start menu and desktop in order to remove those icons that you don't want.  A very common task is to delete the contents of the %ALLUSERSPROFILE%\Start Menu\Programs\Startup folder in order to remove all the icons (for example, older versions of Microsoft Office used to place a shortcut there and so does the Adobe Acrobat Reader installer.  These shortcuts normally launch a program that caches the most common files required for these applications so that they start up quicker each time they are launched.)  To achieve this you might use the following VBS script:

Const DeleteReadOnly = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("%ALLUSERSPROFILE%\Start Menu\Programs\Startup\*.lnk"), DeleteReadOnly

Don't!   I often get phone calls and/or emails asking me why a previously working BDD/MDT system has stopped working without any errors left in the logs at all.  "All I did was add a simple script, honest!" is how the call normally starts.  The culprit is simple; take a look at the below image:

XPStartMenu

The shortcut "LiteTouch.lnk" is what drives your BDD/MDT process and allows it to continue after any reboots you add to the Task Sequence.  So, if you delete the contents of the folder, when your computer reboots, you'll no longer see anything happen afterwards.  Instead, you could use the following script which would still delete the contents of the folder, but leave behind the important BDD/MDT shortcut:

Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
Dim objFSO, objFldr, objFile, ShellPath
ShellPath = WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFldr = objFSO.GetFolder(ShellPath & "\Start Menu\Programs\Startup")

For Each objFile In objFldr.Files

    If objFile.Name <> "LiteTouch.lnk" Then
        objFSO.DeleteFile(objFile.Path)
    End If
Next

Enjoy,

Daniel

This post was contributed by Daniel Oxley a consultant with Microsoft Services Spain.