forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInSandboxScript.ps1
More file actions
121 lines (92 loc) · 3.46 KB
/
Copy pathInSandboxScript.ps1
File metadata and controls
121 lines (92 loc) · 3.46 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Param(
[String] $DesktopAppInstallerPath,
[String[]] $DesktopAppInstallerDependencyPath,
[String] $PackageIdentifier,
[String] $SourceName,
[String] $OutputPath,
[Switch] $UseDev,
[Switch] $MetadataCollection,
[String] $System32Path
)
function Get-ARPTable {
$registry_paths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
return Get-ItemProperty $registry_paths -ErrorAction SilentlyContinue |
Select-Object DisplayName, DisplayVersion, Publisher, @{N='ProductCode'; E={$_.PSChildName}} |
Where-Object {$null -ne $_.DisplayName }
}
$ProgressPreference = 'SilentlyContinue'
$desktopPath = "C:\Users\WDAGUtilityAccount\Desktop"
$regFilesDirPath = Join-Path $desktopPath "RegFiles"
if (Test-Path $regFilesDirPath)
{
foreach ($regFile in (Get-ChildItem $regFilesDirPath))
{
Write-Host @"
--> Importing reg file $($regFile.FullName)
"@
reg import $($regFile.FullName)
}
}
Write-Host @"
--> Installing WinGet
"@
if ($UseDev)
{
foreach($dependency in $DesktopAppInstallerDependencyPath)
{
Write-Host @"
----> Installing $dependency
"@
Add-AppxPackage -Path $dependency
}
Write-Host @"
----> Enabling dev mode
"@
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
$devPackageManifestPath = Join-Path $desktopPath "DevPackage\AppxManifest.xml"
Write-Host @"
----> Installing $devPackageManifestPath
"@
Add-AppxPackage -Path $devPackageManifestPath -Register
}
else
{
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module Microsoft.WinGet.Client -Force | Out-Null
Repair-WingetPackageManager -Latest
}
$originalARP = Get-ARPTable
Write-Host @"
--> Installing $PackageIdentifier
"@
$installAndCorrelateOutPath = Join-Path $OutputPath "install_and_correlate.json"
$installAndCheckCorrelationExe = Join-Path $desktopPath "InstallAndCheckCorrelation\InstallAndCheckCorrelation.exe"
$installAndCheckCorrelationArgs = @('-id', $PackageIdentifier, '-src', $SourceName, '-out', $installAndCorrelateOutPath)
if ($UseDev)
{
$installAndCheckCorrelationArgs += '-dev'
}
if ($MetadataCollection)
{
$wingetUtilPath = Join-Path $PSScriptRoot "WinGetUtil.dll"
$installAndCheckCorrelationArgs += ('-meta', $wingetUtilPath, '-sys32', $System32Path)
}
& $installAndCheckCorrelationExe $installAndCheckCorrelationArgs
Write-Host @"
--> Copying logs
"@
if ($UseDev)
{
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\WinGetDevCLI_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
}
else
{
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
}
Write-Host @"
--> Comparing ARP Entries
"@
$arpCompared = (Compare-Object (Get-ARPTable) $originalARP -Property DisplayName,DisplayVersion,Publisher,ProductCode)
$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table
$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table | Out-File (Join-Path $OutputPath "ARPCompare.txt")
"Done" | Out-File (Join-Path $OutputPath "done.txt")