|
1 |
| -$installationPath = "$($Env:Programfiles)" |
2 |
| -$currentPath = "$(Get-Location)" |
3 |
| -$programPath = $currentPath + "\dist\search" |
4 |
| -$verifyPath = $installationPath + "\search\" |
5 |
| - |
6 |
| -If (Test-Path $verifyPath) { |
7 |
| - try { |
8 |
| - Remove-Item $verifyPath -Recurse |
9 |
| - Write-Host "Previous installation removed" -ForegroundColor Green |
10 |
| - } catch { |
11 |
| - Write-Host "Could not remove the previous installation" -ForegroundColor Red |
12 |
| - Exit 1 |
13 |
| - } |
14 |
| - |
15 |
| - if (Test-Path $programPath) { |
16 |
| - try { |
17 |
| - Copy-Item -Path $programPath -Destination $verifyPath -Recurse |
18 |
| - Write-Host "moved program" -ForegroundColor Green |
19 |
| - } catch { |
20 |
| - Write-Host "Could not move the program" -ForegroundColor Red |
21 |
| - Exit 1 |
22 |
| - } |
23 |
| - |
24 |
| - try { |
25 |
| - $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path |
26 |
| - |
27 |
| - if ($oldpath.split(';') -like $verifyPath) { |
28 |
| - Write-Host "the environment variable already exists" -ForegroundColor Cyan |
29 |
| - } else { |
30 |
| - $newpath = "$oldpath;$verifyPath" |
31 |
| - Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath |
32 |
| - Write-Host "Environment variable created" -ForegroundColor Green |
33 |
| - } |
34 |
| - } catch { |
35 |
| - Host "We could not create your environment variable you will have to do it manually." -ForegroundColor Red |
36 |
| - } |
37 |
| - } else { |
38 |
| - Write-Host "program files do not exist" -ForegroundColor Red |
39 |
| - Exit 1 |
40 |
| - } |
41 |
| -} Else { |
42 |
| - if (Test-Path $programPath) { |
43 |
| - try { |
44 |
| - Copy-Item -Path $programPath -Destination $verifyPath -Recurse |
45 |
| - Write-Host "moved program" -ForegroundColor Green |
46 |
| - } catch { |
47 |
| - Write-Host "Could not move the program" -ForegroundColor Red |
48 |
| - Exit 1 |
49 |
| - } |
50 |
| - |
51 |
| - try { |
52 |
| - $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path |
53 |
| - |
54 |
| - if ($oldpath.split(';') -like $verifyPath) { |
55 |
| - Write-Host "the environment variable already exists" -ForegroundColor Cyan |
56 |
| - } else { |
57 |
| - $newpath = "$oldpath;$verifyPath" |
58 |
| - Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath |
59 |
| - Write-Host "Environment variable created" -ForegroundColor Green |
60 |
| - } |
61 |
| - } catch { |
62 |
| - Host "We could not create your environment variable you will have to do it manually." -ForegroundColor Red |
63 |
| - } |
64 |
| - } else { |
65 |
| - Write-Host "program files do not exist" -ForegroundColor Red |
66 |
| - Exit 1 |
67 |
| - } |
68 |
| -} |
69 |
| - |
70 |
| -Write-Host "Installation process completed" -ForegroundColor Cyan |
| 1 | +$installationPath = "$($Env:Programfiles)" |
| 2 | +$currentPath = "$(Get-Location)" |
| 3 | +$programPath = $currentPath + "\dist\search" |
| 4 | +$verifyPath = $installationPath + "\search\" |
| 5 | + |
| 6 | +If (Test-Path $verifyPath) { |
| 7 | + try { |
| 8 | + Remove-Item $verifyPath -Recurse |
| 9 | + Write-Host "Previous installation removed" -ForegroundColor Green |
| 10 | + } catch { |
| 11 | + Write-Host "Could not remove the previous installation" -ForegroundColor Red |
| 12 | + Exit 1 |
| 13 | + } |
| 14 | + |
| 15 | + if (Test-Path $programPath) { |
| 16 | + try { |
| 17 | + Copy-Item -Path $programPath -Destination $verifyPath -Recurse |
| 18 | + Write-Host "moved program" -ForegroundColor Green |
| 19 | + } catch { |
| 20 | + Write-Host "Could not move the program" -ForegroundColor Red |
| 21 | + Exit 1 |
| 22 | + } |
| 23 | + |
| 24 | + try { |
| 25 | + $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path |
| 26 | + |
| 27 | + if ($oldpath.split(';') -like $verifyPath) { |
| 28 | + Write-Host "the environment variable already exists" -ForegroundColor Cyan |
| 29 | + } else { |
| 30 | + $newpath = "$oldpath;$verifyPath" |
| 31 | + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath |
| 32 | + Write-Host "Environment variable created" -ForegroundColor Green |
| 33 | + } |
| 34 | + } catch { |
| 35 | + Host "We could not create your environment variable you will have to do it manually." -ForegroundColor Red |
| 36 | + } |
| 37 | + } else { |
| 38 | + Write-Host "program files do not exist" -ForegroundColor Red |
| 39 | + Exit 1 |
| 40 | + } |
| 41 | +} Else { |
| 42 | + if (Test-Path $programPath) { |
| 43 | + try { |
| 44 | + Copy-Item -Path $programPath -Destination $verifyPath -Recurse |
| 45 | + Write-Host "moved program" -ForegroundColor Green |
| 46 | + } catch { |
| 47 | + Write-Host "Could not move the program" -ForegroundColor Red |
| 48 | + Exit 1 |
| 49 | + } |
| 50 | + |
| 51 | + try { |
| 52 | + $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path |
| 53 | + |
| 54 | + if ($oldpath.split(';') -like $verifyPath) { |
| 55 | + Write-Host "the environment variable already exists" -ForegroundColor Cyan |
| 56 | + } else { |
| 57 | + $newpath = "$oldpath;$verifyPath" |
| 58 | + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath |
| 59 | + Write-Host "Environment variable created" -ForegroundColor Green |
| 60 | + } |
| 61 | + } catch { |
| 62 | + Host "We could not create your environment variable you will have to do it manually." -ForegroundColor Red |
| 63 | + } |
| 64 | + } else { |
| 65 | + Write-Host "program files do not exist" -ForegroundColor Red |
| 66 | + Exit 1 |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +Write-Host "Installation process completed" -ForegroundColor Cyan |
0 commit comments