-
Notifications
You must be signed in to change notification settings - Fork 127
/
DisableWindowsMediaCenter.ps1
56 lines (48 loc) · 2.67 KB
/
DisableWindowsMediaCenter.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#*******************************************************************************
# Author: Mick Pletcher
# Date: 16 August 2013
#
# Program: Windows Media Center
#*******************************************************************************
cls
#Declare Global Memory
Set-Variable -Name a -Scope Global -Force
Set-Variable -Name Output -Scope Global -Force
Function AddRemovePrograms($KeyName, $DisplayName, $Version){
#Define Local Memory
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Set-Variable -Name AddRemKey -Scope Local -Force
Set-Variable -Name guid -Scope Local -Force
Set-Variable -Name ProductsKey -Scope Local -Force
If (!(Test-Path c:\windows\GSPBox_Icon.bmp)){
Copy-Item -Path \\global.gsp\data\clients\na_clients\Build\Add-ins\GSPBox_Icon.bmp -Destination c:\Windows -Force
}
$AddRemKey = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
$ProductsKey = "HKCR:\Installer\Products\"
New-Item -Path $AddRemKey -Name $KeyName –Force
New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayName -Value $DisplayName -PropertyType String
New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayVersion -Value $Version -PropertyType String
New-ItemProperty -Path $AddRemKey"\"$KeyName -Name UninstallString -Value " " -PropertyType String
New-ItemProperty -Path $AddRemKey"\"$KeyName -Name Publisher -Value "Gresham, Smith and Partners" -PropertyType String
New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayIcon -Value "c:\windows\GSPBox_Icon.bmp" -PropertyType String
$guid = [guid]::NewGuid().ToString("N")
$guid.ToString()
$guid = $guid.ToUpper()
New-Item -Path $ProductsKey -Name $guid –Force
New-ItemProperty -Path $ProductsKey"\"$guid -Name ProductName -Value $DisplayName -PropertyType String -Force
#Cleanup Local Memory
remove-psdrive -name HKCR
Remove-Variable -Name AddRemKey -Scope Local -Force
Remove-Variable -Name guid -Scope Local -Force
Remove-Variable -Name ProductsKey -Scope Local -Force
}
Invoke-Command {dism.exe /online /disable-feature /featurename:MediaCenter /norestart}
$a = Invoke-Command {dism.exe /online /get-featureinfo /featurename:MediaCenter}
$Output = $a | Select-String "State : Disabled"
Write-Host $Output
If ($Output -like "State : Disabled"){
AddRemovePrograms "MediaCenter" "MediaCenter" "Disabled"
}
#Cleanup Global Memory
Remove-Variable -Name a -Scope Global -Force
Remove-Variable -Name Output -Scope Global -Force