-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_install_files_and_services.ps1
executable file
·59 lines (59 loc) · 1.68 KB
/
check_install_files_and_services.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
57
58
59
clear-host
if ((Test-Path 'log_install_files_and_services.txt') -eq 'True') {
clear-content 'log_install_files_and_services.txt'
}
$result = 'True'
$emptypath = @()
$emptyservices = @()
$file_count = 0
$arch = [IntPtr]::Size
$host_os = Get-WmiObject Win32_operatingsystem | Select Caption
if ($host_os.caption.contains('Windows XP')) {
$file = 'for_XP.txt'
}
else {
if ($arch -eq 8) {
$file = 'for_x64_not_XP.txt'
}
elseif ($arch -eq 4) {
$file = 'for_x86_not_XP.txt'
}
}
foreach ($path in get-content $file) {
Clear-host
$file_count += 1
write-host 'Ôàéëîâ ïðîâåðåíî:' $file_count
if ((Test-Path $path) -ne 'True') {
$emptypath += $path
$result = 'False'
}
}
foreach ($line in get-content 'services.txt') {
try {
Get-Service $line -EA stop
}
catch {
$result = 'False'
$emptyservices += $line
}
}
If ($result -eq 'True') {
write-host 'Óñòàíîâêà ïðîøëà óñïåøíî'
}
else {
write-host 'Óñòàíîâêà çàâåðøèëàñü íåóäà÷íî. Ïîäðîáíîñòè â log_install_files_and_services.txt'
If ($emptypath -ne 0) {
'Íå íàéäåíû ñëåäóþùèå ôàéëû:' >> log_install_files_and_services.txt
foreach ($line in $emptypath) {
$line >> log_install_files_and_services.txt
}
}
If ($emptyservices -ne 0) {
'Íå íàéäåíû ñëåäóþùèå ñëóæáû:' >> log_install_files_and_services.txt
foreach ($line in $emptyservices) {
$line >> log_install_files_and_services.txt
}
}
}
Write-Host "Äëÿ âûõîäà íàæìèòå ëþáóþ êëàâèøó"
cmd /c pause | out-null