'Show Hidden Add/Remove Components 'This script will show hidden Windows Components in the Add and Remove Programs applet. 'ShowHidAddRem.vbs '© Robert Dunham - 1/23/2006 'Downloaded from http://www.nilpo.com Option Explicit Dim objFs, oFile, iFile, objParam, sFile, WshShell Dim message, result, strLine, strParam, strPath, uPath, strName, strScript, strWinPath Const ForReading = 1, strFind = "hide", strReplace = "" On Error Resume Next ' Set global variables Set WshShell = CreateObject("WScript.Shell") strName = WScript.ScriptName strPath = WScript.Path + "\" strScript = WScript.ScriptFullName uPath = "%UserProfile%\" uPath = WshShell.ExpandEnvironmentStrings(uPath) If Left(uPath, 1) = "%" Then uPath = WshShell.ExpandEnvironmentStrings("%WinDir%") & "\" End If strWinPath = "%WinDir%" strWinPath = WshShell.ExpandEnvironmentStrings(strWinPath) ' Check for undo parameter (ignore case) Set objParam = Wsh.Arguments If objParam.Count > 1 Then Call ErrSyntax Elseif objParam.Count = 1 Then For Each strParam In objParam If strParam = "undo" Then message = "This will remove all changes made to the Add and Remove Programs applet." + vbcr + vbcr message = message + "Do you want to continue?" result = MsgBox(message, _ vbYesNo + vbQuestion + vbDefaultButton1 + vbSystemModal, _ "Hide Add/Remove Components") If result = vbNo Then Set objParam = Nothing Wscript.Quit End If ' Establish file system object and get files Set objFs = CreateObject("Scripting.FileSystemObject") If objFs.FileExists(strWinPath & "\inf\sysoc.fni") Then Set oFile = objFs.GetFile(strWinPath & "\inf\sysoc.fni") If objFs.FileExists(strWinPath & "\inf\sysoc.inf") Then Set iFile = objFs.GetFile(strWinPath & "\inf\sysoc.inf") iFile.Delete True End If oFile.Move strWinPath & "\inf\sysoc.inf" If Err = 0 Then message = "The backup has been successfully restored." + vbcr + vbcr message = message + "Script provided by Nilpo.com" MsgBox message, vbOkOnly + vbInformation, "Hide Add/Remove Components" Else message = "An error may have occured while restoring the backup." MsgBox message, vbOkOnly + vbCritical, "Script Ended" End If Set sFile = objFs.GetFile(strScript) sFile.Delete Else message = "There is no backup file to restore. The script cannot continue." MsgBox message, vbOkOnly + vbCritical, "Error" End If Else Call ErrSyntax End If Next Else ' Display a description of the file's purpose and allow user abort. message = "This script will show hidden Windows Components in the Add and Remove Programs applet." + vbcr +vbcr message = message + "Do you want to continue?" result = msgBox(message, _ VBYesNo + vbQuestion + vbDefaultButton2 + vbSystemModal, _ "Show Hidden Add/Remove Components") If result = vbNo Then Set WshShell = Nothing Set objParam = Nothing WScript.Quit End If ' Establish the FileSystem Object Set objFs = CreateObject("Scripting.FileSystemObject") ' Check if sysoc.inf exists (it should always), and open it If objFs.FileExists(strWinPath & "\inf\sysoc.inf") Then Set oFile = objFs.GetFile(strWinPath & "\inf\sysoc.inf") ' Create backup file by renaming the original oFile.Move strWinPath & "\inf\sysoc.fni" ' Error-check to see if backup was created, end script if it was unsuccessful If Err <> 0 Then message = "The script was unable to successfully create a backup file. The script will not continue." MsgBox message, vbOkOnly + vbCritical, "Script Error" ' Empty buffer and quit Set WshShell = Nothing Set objParam = Nothing Set objFs = Nothing Set oFile = Nothing Set sFile = Nothing Wscript.Quit End If ' Set input file Set iFile = objFs.OpenTextFile(strWinPath & "\inf\sysoc.fni", ForReading, False) ' Recreate original file for output Set oFile = objFs.CreateTextFile(strWinPath & "\inf\sysoc.inf", True) ' Read each line, check for string replacing if necessary and then write to output file Do While Not iFile.AtEndOfStream strLine = iFile.ReadLine strLine = Replace(strLine, strFind, strReplace, 1, -1, 1) oFile.WriteLine(strLine) Loop iFile.Close oFile.Close ' Copy script to system directory for uninstall purposes Set sFile = objFs.GetFile(strScript) sFile.Copy uPath & strName, True ' Display confirmation message message = "The script completed successfully. A backup file was created for you." + vbcr + vbcr message = message + "To undo changes made by this script, click the Start Button and choose Run... " + vbcr message = message + "Enter the following command in the dialog and click OK." + vbcr + vbcr message = message + " wscript.exe " + strName message = message + " undo" + vbcr + vbcr message = message + "Script provided by Nilpo.com" MsgBox message, vbOKOnly + vbInformation, "Script Completed" Else ' Display error - couldn't find sysoc.inf message = "The script was unable to find the required file. The script cannot continue." MsgBox message, vbOKOnly + vbCritical, "Script Terminated" End If End If ' Empty buffer and end script Set WshShell = Nothing Set objParam = Nothing Set objFs = Nothing Set oFile = Nothing Set iFile = Nothing Set sFile = Nothing Wscript.Quit Sub ErrSyntax ' Invalid parameter(s) message = "Please check command syntax and try again. Script aborted." MsgBox message, vbOkOnly + vbCritical, "Invalid Syntax" End Sub