forked from DeploymentResearch/DRFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig-EnableWindowsStoreUpdates.wsf
77 lines (63 loc) · 2.78 KB
/
Config-EnableWindowsStoreUpdates.wsf
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<job id="Config-EnableWindowsStoreUpdates">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">
If oEnvironment.Item("_SMSTSInWinPE") = "true" Then
oLogging.CreateEntry "Getting current OS drive letter", LogTypeInfo
sSystemDrive = oEnvironment.Item("OSDTARGETDRIVECACHE")
oLogging.CreateEntry "Current OS drive letter is " & sSystemDrive, LogTypeInfo
oLogging.CreateEntry "About to configure offline registry settings", LogTypeInfo
oLogging.CreateEntry "Windows version applied to harddrive is" & oEnvironment.Item("IMAGEBUILD"), LogTypeInfo
UpdateOfflineRegistry(sSystemDrive)
End If
Function UpdateOfflineRegistry(sSystemDrive)
oLogging.CreateEntry "Load the offline registry file", LogTypeInfo
bFound = False
For each sDir in oFSO.GetFolder(sSystemDrive & "\").Subfolders
If oFSO.FileExists(sDir & "\system32\config\software") then
oLogging.CreateEntry "Trying to load registry file " & sDir & "\system32\config\software", LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("reg load HKLM\NewOS """ & sDir & "\system32\config\software""")
If iRetVal = SUCCESS then
bFound = True
exit for
Else
sLoadOfflineRegistry = ""
End if
End If
Next
If not bFound then
oLogging.CreateEntry "Unable to find the new OS registry file; Windows Store settings cannot be updated.", LogTypeError
UpdateDevicePath = Success
EXIT FUNCTION
End If
UpdateOfflineRegistry = Success
End Function
oLogging.CreateEntry "Enable Windows Store Updates", LogTypeInfo
If oEnvironment.Item("_SMSTSInWinPE") = "true" Then
oShell.RegDelete "HKEY_LOCAL_MACHINE\NewOS\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate\AutoDownload"
Else
oShell.RegDelete "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate\AutoDownload"
End If
If Err.Number <> 0 Then
oLogging.CreateEntry "Could not delete the key, probably not exist", LogTypeInfo
Else
oLogging.CreateEntry "Key deleted successfully", LogTypeInfo
End If
Err.Clear
oLogging.CreateEntry "Enable Consumer Experience", LogTypeInfo
If oEnvironment.Item("_SMSTSInWinPE") = "true" Then
oShell.RegDelete "HKEY_LOCAL_MACHINE\NewOS\Policies\Microsoft\Windows\CloudContent\DisableWindowsConsumerFeatures"
Else
oShell.RegDelete "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CloudContent\DisableWindowsConsumerFeatures"
End If
If Err.Number <> 0 Then
oLogging.CreateEntry "Could not delete the key, probably not exist", LogTypeInfo
Else
oLogging.CreateEntry "Key deleted successfully", LogTypeInfo
End If
Err.Clear
If oEnvironment.Item("_SMSTSInWinPE") = "true" Then
oLogging.CreateEntry "Unload the offline registry file", LogTypeInfo
oShell.Run "reg unload HKLM\NewOS", 0, true
End If
</script>
</job>