Delete invalid shortcut on the Start screen in Windows 8 (VBScript)

Introduction

This script shows how to remove invalid shortcut on the Start screen.

Scenarios

Sometimes when you uninstall software on your computer, even though the software is uninstalled successfully, it leaves some shortcuts that were created behind in your computer. These shortcuts do not work as the related softwares are uninstalled. Perhaps you move a file or a folder to a different location, the shortcut to that file or folder becomes invalid as it still points to the earlier location.

Script

Step: Double-click on the script. If there is any invalid shortcut on the Start menu, it will show message like “Removing invalid shortcut : ***”.

As you can see, there is a shortcut file on the Start screen called Document. Actually, the shortcut file was invalid.

The result is shown below:

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

VB Script
Edit|Remove
Dim objFSO,objshell,envUSER 
Dim objUserFolder,objSysFolder,UserFolder,SysFolder      
'Create "Scripting.FileSystemObject" object  
Set objFSO = CreateObject("Scripting.FileSystemObject")  
'Create "Wscript.shell" object  
Set objshell = CreateObject("wscript.shell") 
'Get the current username 
envUSER = objshell.expandEnvironmentStrings("%username%") 
'The path of personal start menu  
objUserFolder = "C:\Users\" & envUSER & "\AppData\Roaming\Microsoft\Windows\Start Menu" 
'The path of the system start menu 
objSysFolder = "C:\ProgramData\Microsoft\Windows\Start Menu" 
Set UserFolder = objFSO.GetFolder(objUserFolder) 
DeleteShortcut UserFolder 
Set SysFolder = objFSO.GetFolder(objSysFolder) 
DeleteShortcut SysFolder

Prerequisite

Windows 8