-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-SplashScreen.ps1
More file actions
115 lines (102 loc) · 3.51 KB
/
Copy pathInvoke-SplashScreen.ps1
File metadata and controls
115 lines (102 loc) · 3.51 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
# Import the necessary WPF assemblies
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase
# Set the path to the image file for the splash screen
$imagePath = "C:\path\image.png"
# Set the path to the check mark image file
$checkMarkPath = "C:\path\check.png"
# Define the paths to check for
$pathsToCheck = @{
"RegistryKey" = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome",
"Folder" = "C:\Program Files\Google\Chrome",
"File" = "C:\Program Files\Google\Chrome\Application\chrome.exe"
}
# Create a new WPF window for the splash screen
$splashScreen = New-Object System.Windows.Window
$splashScreen.SizeToContent = "WidthAndHeight"
$splashScreen.WindowStyle = "ToolWindow"
$splashScreen.Background = New-Object System.Windows.Media.SolidColorBrush([System.Windows.Media.Color]::FromArgb(0, 0, 0, 0))
# Load the image and set it as the content of the window
$image = [System.Windows.Media.Imaging.BitmapImage]::new()
$image.BeginInit()
$image.UriSource = [System.Uri]::new($imagePath)
$image.EndInit()
$imageControl = New-Object System.Windows.Controls.Image
$imageControl.Source = $image
$splashScreen.Content = $imageControl
# Create a timer for the countdown
$countdownSeconds = 10
$timer = New-Object System.Windows.Threading.DispatcherTimer
$timer.Interval = [TimeSpan]::FromSeconds(1)
$timer.Add_Tick({
$countdownSeconds--
if ($countdownSeconds -eq 0) {
$timer.Stop()
$splashScreen.Close()
}
})
# Add the timer to the splash screen
$splashScreen.Add_Loaded({
$timer.Start()
})
# Show the splash screen
$splashScreen.WindowStartupLocation = "CenterScreen"
$splashScreen.Show()
# Loop over each path type to check
foreach ($pathType in $pathsToCheck.Keys) {
try {
# Check for the existence of registry keys, files, folders, and software
switch ($pathType) {
"RegistryKey" {
$appName = "Google Chrome"
if (Get-ItemProperty -Path $pathsToCheck[$pathType] -Name DisplayName -ErrorAction Stop) {
Write-Output "$appName is installed"
}
else {
Write-Output "$appName is not installed"
}
}
"Folder" {
if (Test-Path $pathsToCheck[$pathType]) {
Write-Output "Folder $($pathsToCheck[$pathType]) exists"
}
else {
Write-Output "Folder $($pathsToCheck[$pathType]) does not exist"
}
}
"File" {
if (Test-Path $pathsToCheck[$pathType]) {
Write-Output "File $($pathsToCheck[$pathType]) exists"
}
else {
Write-Output "File $($pathsToCheck[$pathType]) does not exist"
}
}
Default {
Write-Warning "Unknown path type: $pathType"
}
}
}
catch {
Write-Error "Error checking $pathType $($pathsToCheck[$pathType]): $_"
}
}
# Show the splash screen
$splashScreen.WindowStartupLocation = "CenterScreen"
$splashScreen.Show()
# Loop over each path to check
foreach ($path in $pathsToCheck) {
try {
# Check if the path exists
if (Test-Path $path) {
Write-Output "Path $path exists"
}
else {
Write-Output "Path $path does not exist"
}
}
catch {
# Write-Error "Error checking path $path: $_"
}
}