-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkur_windows.ps1
More file actions
635 lines (552 loc) · 25.5 KB
/
Copy pathkur_windows.ps1
File metadata and controls
635 lines (552 loc) · 25.5 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
#=======================================================
# Python Ocağı - Windows Kurulum ve Başlatma Betiği
# İnteraktif menü ile kurulum, direkt kullanım ve kaldırma
#=======================================================
param (
[switch]$AutoUpdate
)
# TLS 1.2 Zorunlulugu (Geriye Donuk Uyumluluk)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# GitHub Repo Bilgileri
$REPO_OWNER = "brkeyp"
$REPO_NAME = "python-ocagi"
$BRANCH = "main"
# URL ve Dizin Tanimlari
$ZIP_URL = "https://github.com/$REPO_OWNER/$REPO_NAME/archive/refs/heads/$BRANCH.zip"
$DesktopPath = [Environment]::GetFolderPath("Desktop")
$AppFolder = Join-Path $DesktopPath "Python Ocagi"
$ShortcutPath = Join-Path $DesktopPath "PYTHON OCAGINA GIR.lnk"
$UninstallPath = Join-Path $AppFolder "Uygulamayi Kaldir.bat"
$TempAppDir = Join-Path $env:TEMP "python_ocagi_hemenbasla"
# Gecici dosya yollari
$TempZip = Join-Path $env:TEMP "python_ocagi_update.zip"
$TempExtract = Join-Path $env:TEMP "python_ocagi_extracted"
# Script-scope Python komutu
$script:PythonCmd = ""
#=======================================================
# YARDIMCI FONKSIYONLAR
#=======================================================
function Read-SingleKey {
$key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
return $key
}
function Refresh-SessionPath {
<# Registry'den guncel PATH degerlerini okuyup mevcut oturuma uygular.
Python kurulumu sonrasi py/python komutlarinin bulunabilmesi icin gereklidir. #>
try {
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$env:Path = "$machinePath;$userPath"
}
catch {}
}
function Download-AppTo {
param([string]$TargetDir)
if (-not (Test-Path $TargetDir)) {
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
}
Write-Host ""
Write-Host "Uygulama indiriliyor..." -ForegroundColor Cyan
Write-Host " (Internet hiziniza gore degisir)" -ForegroundColor DarkGray
$ProgressPreference = 'SilentlyContinue'
try {
Invoke-WebRequest -Uri $ZIP_URL -OutFile $TempZip -UseBasicParsing
if (Test-Path $TempExtract) {
Remove-Item -Path $TempExtract -Recurse -Force
}
Expand-Archive -Path $TempZip -DestinationPath $TempExtract -Force
Copy-Item -Path (Join-Path $TempExtract "$REPO_NAME-$BRANCH\*") -Destination $TargetDir -Recurse -Force | Out-Null
# Temizlik
Remove-Item -Path $TempZip -Force -ErrorAction SilentlyContinue
Remove-Item -Path $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Indirme tamamlandi." -ForegroundColor Green
}
catch {
Write-Host "Indirme sirasinda hata olustu: $_" -ForegroundColor Yellow
Write-Host "Mevcut surumle devam ediliyor..." -ForegroundColor Yellow
}
}
#=======================================================
# PYTHON KONTROL VE KURULUM
#=======================================================
function Show-ManualPythonInstructions {
Write-Host ""
Write-Host "Python'u manuel olarak yuklemek icin:" -ForegroundColor Yellow
Write-Host " python.org/downloads adresinden Python 3.13 indirin." -ForegroundColor White
Write-Host " Kurulum sirasinda 'Add to PATH' secenegini isaretleyin." -ForegroundColor White
Write-Host ""
Write-Host "Yukledikten sonra bu komutu tekrar calistirin." -ForegroundColor DarkGray
}
function Install-PythonWithPermission {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Red
Write-Host "Python bulunamadi!" -ForegroundColor Yellow
Write-Host "=========================================" -ForegroundColor Red
Write-Host ""
Write-Host "Bu uygulama calismak icin Python 3.13 gerektirir." -ForegroundColor White
Write-Host ""
Write-Host "Otomatik olarak yuklemek ister misiniz?" -ForegroundColor White
Write-Host ""
Write-Host " [E] Evet, yukle" -ForegroundColor Green
Write-Host " [H] Hayir, kendim yukleyecegim" -ForegroundColor Red
Write-Host ""
Write-Host -NoNewline "Seciminiz: " -ForegroundColor Cyan
$key = Read-SingleKey
Write-Host ""
if ($key.Character -match '[EeYy]' -or $key.VirtualKeyCode -eq 13) {
Write-Host ""
Write-Host "Python 3.13 internetten indiriliyor..." -ForegroundColor Cyan
Write-Host "(Bu islem internet hizina bagli olarak birkac dakika surebilir)" -ForegroundColor DarkGray
# Mimari tespiti
try {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture
if ($arch -eq 'Arm64') {
$InstallerUrl = "https://www.python.org/ftp/python/3.13.11/python-3.13.11-arm64.exe"
$InstallerFile = "python-3.13.11-arm64.exe"
}
else {
$InstallerUrl = "https://www.python.org/ftp/python/3.13.11/python-3.13.11-amd64.exe"
$InstallerFile = "python-3.13.11-amd64.exe"
}
}
catch {
# Eski PowerShell surumleri icin fallback
$InstallerUrl = "https://www.python.org/ftp/python/3.13.11/python-3.13.11-amd64.exe"
$InstallerFile = "python-3.13.11-amd64.exe"
}
$InstallerPath = Join-Path $env:TEMP $InstallerFile
try {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath -UseBasicParsing
Write-Host ""
Write-Host "Python sessizce kuruluyor. Lutfen pencereyi kapatmayin..." -ForegroundColor Yellow
Start-Process -FilePath $InstallerPath -ArgumentList "/quiet InstallAllUsers=0 PrependPath=0 Include_launcher=1 Include_pip=1" -Wait
# PATH'i yenile (yeni kurulan Python'u bulsun)
Refresh-SessionPath
# Dogrulama — gercek calisip calismadigini kontrol et
$PyCheck = Get-Command "py" -ErrorAction SilentlyContinue
if ($PyCheck) {
try {
$ver = & py --version 2>&1
if ($ver -match "Python 3\.") {
$script:PythonCmd = "py"
Write-Host ""
Write-Host "Python basariyla yuklendi!" -ForegroundColor Green
return $true
}
}
catch {}
}
$PyCheck = Get-Command "python" -ErrorAction SilentlyContinue
if ($PyCheck) {
try {
$ver = & python --version 2>&1
if ($ver -match "Python 3\.") {
$script:PythonCmd = "python"
Write-Host ""
Write-Host "Python basariyla yuklendi!" -ForegroundColor Green
return $true
}
}
catch {}
}
# Son care: varsayilan kurulum konumunu kontrol et
$defaultPyLauncher = Join-Path $env:LOCALAPPDATA "Programs\Python\Launcher\py.exe"
if (Test-Path $defaultPyLauncher) {
$script:PythonCmd = $defaultPyLauncher
Write-Host ""
Write-Host "Python basariyla yuklendi!" -ForegroundColor Green
return $true
}
Write-Host "Python kurulumu tamamlandi ancak dogrulanamadi." -ForegroundColor Yellow
Write-Host "Bu pencereyi kapatip komutu tekrar calistirin." -ForegroundColor Yellow
pause
exit 0
}
catch {
Write-Host "Python indirme/kurulum hatasi: $_" -ForegroundColor Red
Show-ManualPythonInstructions
pause
exit 1
}
}
else {
Show-ManualPythonInstructions
pause
exit 0
}
}
function Test-PythonAvailable {
<# Python'un gercekten yuklu ve calisir durumda olduğunu dogrular.
Windows 10/11'deki Microsoft Store 'python.exe' alias'i
Get-Command ile bulunur ama gercek Python degildir.
Bu yuzden komut bulunduktan sonra --version ile dogrulama yapilir. #>
# 1. py launcher ile dene (en guvenilir)
$PyLauncher = Get-Command "py" -ErrorAction SilentlyContinue
if ($PyLauncher) {
try {
$ver = & py --version 2>&1
if ($ver -match "Python 3\.") {
$script:PythonCmd = "py"
return $true
}
}
catch {}
}
# 2. python komutu ile dene (Store alias kontrollu)
$PythonExe = Get-Command "python" -ErrorAction SilentlyContinue
if ($PythonExe) {
try {
$ver = & python --version 2>&1
if ($ver -match "Python 3\.") {
$script:PythonCmd = "python"
return $true
}
}
catch {}
}
# 3. Son care: varsayilan kurulum konumunu kontrol et
$defaultPyLauncher = Join-Path $env:LOCALAPPDATA "Programs\Python\Launcher\py.exe"
if (Test-Path $defaultPyLauncher) {
try {
$ver = & $defaultPyLauncher --version 2>&1
if ($ver -match "Python 3\.") {
$script:PythonCmd = $defaultPyLauncher
return $true
}
}
catch {}
}
return $false
}
#=======================================================
# KARSILAMA EKRANLARI
#=======================================================
function Show-Welcome {
Clear-Host
Write-Host ""
Write-Host "==================================================" -ForegroundColor Cyan
Write-Host " P Y T H O N O C A G I" -ForegroundColor White
Write-Host " Yazarak Ogrenme Platformu" -ForegroundColor DarkGray
Write-Host " Veri Analizi Okulu - VAO" -ForegroundColor Magenta
Write-Host "==================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Hos geldin! Python Ocagi, terminal tabanli"
Write-Host "interaktif bir Python ogrenme platformudur."
Write-Host ""
Write-Host " 98 interaktif ders (16 bolum)" -ForegroundColor Cyan
Write-Host " Kodun guvenli sandbox ortaminda calisir" -ForegroundColor Green
Write-Host " Gercek zamanli syntax highlighting" -ForegroundColor Yellow
Write-Host " Ilerleme otomatik kaydedilir" -ForegroundColor Magenta
Write-Host ""
Write-Host " Ilerleme verilerin bilgisayarinda guvenle saklanir." -ForegroundColor DarkGray
Write-Host " Silmedigin veya uygulama icinden sifirlamedigin" -ForegroundColor DarkGray
Write-Host " surece kaldigin yerden devam edersin." -ForegroundColor DarkGray
Write-Host ""
Write-Host "--------------------------------------------------" -ForegroundColor Cyan
Write-Host ""
Write-Host " [Enter] Hemen Basla" -ForegroundColor Green
Write-Host " [K] Bilgisayarima Kur" -ForegroundColor Yellow
Write-Host " [Q] Cikis" -ForegroundColor Red
Write-Host ""
Write-Host -NoNewline "Seciminiz: " -ForegroundColor Cyan
}
function Show-InstalledMenu {
Clear-Host
Write-Host ""
Write-Host "==================================================" -ForegroundColor Cyan
Write-Host " P Y T H O N O C A G I" -ForegroundColor White
Write-Host "==================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host " Python Ocagi zaten bilgisayariniza kurulu." -ForegroundColor Green
Write-Host " Masaustunuzdeki kisayol ile de acabilirsiniz." -ForegroundColor DarkGray
Write-Host ""
Write-Host "--------------------------------------------------" -ForegroundColor Cyan
Write-Host ""
Write-Host " [Enter] Guncelle ve Basla" -ForegroundColor Green
Write-Host " [K] Uygulamayi Kaldir" -ForegroundColor Red
Write-Host " [Q] Cikis" -ForegroundColor Red
Write-Host ""
Write-Host -NoNewline "Seciminiz: " -ForegroundColor Cyan
}
#=======================================================
# ANA FONKSIYONLAR
#=======================================================
function Invoke-DirectRun {
Download-AppTo -TargetDir $TempAppDir
Write-Host ""
Write-Host "Baslatiliyor..." -ForegroundColor Green
Start-Sleep -Seconds 1
Clear-Host
Set-Location $TempAppDir
$launched = $false
try {
if ($script:PythonCmd -eq "py" -or $script:PythonCmd -like "*py.exe") {
& $script:PythonCmd -3.13 main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
if (-not $launched) {
Write-Host "py -3.13 calismadi, python ile deneniyor..." -ForegroundColor Yellow
& $script:PythonCmd main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
}
}
else {
& $script:PythonCmd main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
}
}
catch {
Write-Host "Hata: $_" -ForegroundColor Red
}
if (-not $launched) {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Red
Write-Host "Uygulama baslatilirken bir sorun olustu." -ForegroundColor Red
Write-Host "=========================================" -ForegroundColor Red
Write-Host ""
Write-Host "Python 3.13 yuklu ve calisir durumda oldugundan" -ForegroundColor Yellow
Write-Host "emin olun. python.org/downloads adresinden" -ForegroundColor Yellow
Write-Host "Python 3.13 indirip kurabilirsiniz." -ForegroundColor Yellow
Write-Host ""
pause
}
}
function Invoke-Install {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "Kurulum basliyor..." -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""
# 1. Klasoru Olustur
if (-not (Test-Path -Path $AppFolder)) {
New-Item -ItemType Directory -Force -Path $AppFolder | Out-Null
Write-Host "Masaustunde 'Python Ocagi' klasoru olusturuldu." -ForegroundColor Green
}
# 2. Baslatma motorunu indir
Write-Host "Baslatma motoru indiriliyor..." -ForegroundColor Cyan
$BaslatUrl = "https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/baslat.ps1"
$BaslatPath = Join-Path $AppFolder "baslat.ps1"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $BaslatUrl -OutFile $BaslatPath -UseBasicParsing
# 3. Kisa Yol Olustur (Masaustu .lnk)
Write-Host "Masaustu kisayolu ayarlaniyor..." -ForegroundColor Cyan
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = "powershell.exe"
$Shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$AppFolder\baslat.ps1`""
$Shortcut.WorkingDirectory = $AppFolder
$Shortcut.Description = "Python Ocagi - Yazarak Ogrenme"
$Shortcut.Save()
# 4. Kaldirma Dosyasi Olustur
Write-Host "Kaldirma araci hazirlaniyor..." -ForegroundColor Cyan
$LnkName = "PYTHON OCAGINA GIR.lnk"
$UninstallScript = @"
@echo off
title Python Ocagi - Kaldirma
color 4F
echo =======================================================
echo DIKKAT: Python Ocagi sisteminizden kaldirilacaktir.
echo.
set /p DEL_PROG="Ilerlemenizi (cozdugunuz sorular ve puanlar) silmek istiyor musunuz? (E/H): "
echo =======================================================
echo Kaldirma islemi baslatildi...
:: Klasor kilidini kirmak icin dizini ev dizinine (USERPROFILE) degistir
cd /d "%USERPROFILE%"
start "" powershell -NoProfile -ExecutionPolicy Bypass -Command "`$del_prog='%DEL_PROG%'; Start-Sleep -Seconds 2; Write-Host 'Uygulama dosyalari siliniyor...' -ForegroundColor Red; Remove-Item -Path (Join-Path ([Environment]::GetFolderPath('Desktop')) 'Python Ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path (Join-Path ([Environment]::GetFolderPath('Desktop')) '$LnkName') -Force -ErrorAction SilentlyContinue; if (`$del_prog -match '^[EeYy]') { Write-Host 'Ilerleme verileri siliniyor...' -ForegroundColor Red; Remove-Item -Path (Join-Path `$env:APPDATA 'python_ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path (Join-Path `$HOME '.python_ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Write-Host 'Her sey silindi.' -ForegroundColor DarkGray } else { Write-Host 'Ilerleme verileri SAKLANDI.' -ForegroundColor Green }; Write-Host ''; Write-Host 'Kaldirma tamamlandi! Bu pencere kapanacak.' -ForegroundColor Green; Start-Sleep -Seconds 3"
exit
"@
# BOM'suz yaz (kritik! BOM .bat dosyalarini bozar)
[System.IO.File]::WriteAllText($UninstallPath, $UninstallScript, [System.Text.UTF8Encoding]::new($false))
Write-Host ""
Write-Host "=========================================" -ForegroundColor Green
Write-Host "KURULUM TAMAMLANDI!" -ForegroundColor Green
Write-Host "=========================================" -ForegroundColor Green
Write-Host "Uygulamayi hemen baslatmak uzere masaustunuzdeki dosyaya ulasiliyor..." -ForegroundColor Cyan
Start-Sleep -Seconds 2
# 5. Ilk Indirme (Kisayolu cagirarak yapalim)
Start-Process -FilePath $ShortcutPath
Start-Sleep -Seconds 1
# Kurulum penceresini temiz kapat
exit 0
}
function Invoke-Uninstall {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Red
Write-Host "DIKKAT: Python Ocagi kaldirilacak!" -ForegroundColor Red
Write-Host "Uygulama dosyalari silinecek." -ForegroundColor Red
Write-Host "=========================================" -ForegroundColor Red
Write-Host ""
Write-Host "Iptal etmek icin bu pencereyi kapatin." -ForegroundColor White
Write-Host -NoNewline "Devam etmek icin ENTER'a basin... " -ForegroundColor White
Read-Host
Write-Host ""
Write-Host "Ilerlemeniz (cozdugunuz sorular ve puanlar) silinsin mi?" -ForegroundColor Yellow
Write-Host " [E] Evet, her seyi sil" -ForegroundColor Red
Write-Host " [H] Hayir, ilerlememi sakla (Hemen Basla ile devam edilebilir)" -ForegroundColor Green
Write-Host ""
Write-Host -NoNewline "Seciminiz: " -ForegroundColor Cyan
$key = Read-SingleKey
Write-Host ""
# Klasor kilidini kirmak icin dizini ev dizinine degistir
Set-Location -Path $env:USERPROFILE
# Her seyi sil
Remove-Item -Path $AppFolder -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path $ShortcutPath -Force -ErrorAction SilentlyContinue
if ($key.Character -match '[EeYy]') {
Remove-Item -Path (Join-Path $env:APPDATA "python_ocagi") -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path (Join-Path $HOME ".python_ocagi") -Recurse -Force -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "Uygulama ve ilerleme verileriniz tamamen silindi." -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Uygulama verileri silindi. Ilerleme verileriniz SAKLANDI." -ForegroundColor Green
}
Write-Host ""
pause
}
function Invoke-UpdateAndLaunch {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "Guncelleme indiriliyor..." -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
# 1. Zip'i indir - internet baglantisini test et
$TempZipAuto = Join-Path $env:TEMP "python_ocagi_update.zip"
$TempExtractAuto = Join-Path $env:TEMP "python_ocagi_extracted"
try {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $ZIP_URL -OutFile $TempZipAuto -UseBasicParsing
if (Test-Path $TempExtractAuto) { Remove-Item -Path $TempExtractAuto -Recurse -Force -ErrorAction SilentlyContinue }
Expand-Archive -Path $TempZipAuto -DestinationPath $TempExtractAuto -Force
} catch {
Write-Host "Baglanti hatasi. Guncelleme yapilamadi." -ForegroundColor Red
pause
exit 1
}
# 2. Bekle (eger baslat.ps1 tarafindan cagirildiysa klasor kilidi cozulsun)
Start-Sleep -Seconds 2
# 3. Klasoru ve kisayolu TAMAMEN SIL
Remove-Item -Path $AppFolder -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path $ShortcutPath -Force -ErrorAction SilentlyContinue
# 4. Yeniden olustur
New-Item -ItemType Directory -Force -Path $AppFolder | Out-Null
$BaslatUrl = "https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/baslat.ps1"
$BaslatPath = Join-Path $AppFolder "baslat.ps1"
Invoke-WebRequest -Uri $BaslatUrl -OutFile $BaslatPath -UseBasicParsing -ErrorAction SilentlyContinue
# Kisa Yol Olustur (Masaustu .lnk)
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = "powershell.exe"
$Shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$AppFolder\baslat.ps1`""
$Shortcut.WorkingDirectory = $AppFolder
$Shortcut.Description = "Python Ocagi - Yazarak Ogrenme"
$Shortcut.Save()
# Kaldirma Dosyasi Olustur
$LnkName = "PYTHON OCAGINA GIR.lnk"
$UninstallScript = @"
@echo off
title Python Ocagi - Kaldirma
color 4F
echo =======================================================
echo DIKKAT: Python Ocagi sisteminizden kaldirilacaktir.
echo.
set /p DEL_PROG="Ilerlemenizi (cozdugunuz sorular ve puanlar) silmek istiyor musunuz? (E/H): "
echo =======================================================
echo Kaldirma islemi baslatildi...
:: Klasor kilidini kirmak icin dizini ev dizinine (USERPROFILE) degistir
cd /d "%USERPROFILE%"
start "" powershell -NoProfile -ExecutionPolicy Bypass -Command "`$del_prog='%DEL_PROG%'; Start-Sleep -Seconds 2; Write-Host 'Uygulama dosyalari siliniyor...' -ForegroundColor Red; Remove-Item -Path (Join-Path ([Environment]::GetFolderPath('Desktop')) 'Python Ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path (Join-Path ([Environment]::GetFolderPath('Desktop')) '$LnkName') -Force -ErrorAction SilentlyContinue; if (`$del_prog -match '^[EeYy]') { Write-Host 'Ilerleme verileri siliniyor...' -ForegroundColor Red; Remove-Item -Path (Join-Path `$env:APPDATA 'python_ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path (Join-Path `$HOME '.python_ocagi') -Recurse -Force -ErrorAction SilentlyContinue; Write-Host 'Her sey silindi.' -ForegroundColor DarkGray } else { Write-Host 'Ilerleme verileri SAKLANDI.' -ForegroundColor Green }; Write-Host ''; Write-Host 'Kaldirma tamamlandi! Bu pencere kapanacak.' -ForegroundColor Green; Start-Sleep -Seconds 3"
exit
"@
[System.IO.File]::WriteAllText($UninstallPath, $UninstallScript, [System.Text.UTF8Encoding]::new($false))
# 5. Indirilenleri iceri tasi
Copy-Item -Path (Join-Path $TempExtractAuto "$REPO_NAME-$BRANCH\*") -Destination $AppFolder -Recurse -Force | Out-Null
# Temizlik
Remove-Item -Path $TempZipAuto -Force -ErrorAction SilentlyContinue
Remove-Item -Path $TempExtractAuto -Recurse -Force -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "Guncelleme tamamlandi. Baslatiliyor..." -ForegroundColor Green
Start-Sleep -Seconds 1
Clear-Host
# 6. Uygulamayi Ac
Set-Location $AppFolder
$launched = $false
try {
if ($script:PythonCmd -eq "py" -or $script:PythonCmd -like "*py.exe") {
& $script:PythonCmd -3.13 main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
if (-not $launched) {
Write-Host "py -3.13 calismadi, python ile deneniyor..." -ForegroundColor Yellow
& $script:PythonCmd main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
}
}
else {
& $script:PythonCmd main.py
if ($LASTEXITCODE -eq 0) { $launched = $true }
}
}
catch {
Write-Host "Hata: $_" -ForegroundColor Red
}
if (-not $launched) {
Write-Host ""
Write-Host "=========================================" -ForegroundColor Red
Write-Host "Uygulama baslatilirken bir sorun olustu." -ForegroundColor Red
Write-Host "=========================================" -ForegroundColor Red
Write-Host ""
Write-Host "Python 3.13 yuklu ve calisir durumda oldugundan" -ForegroundColor Yellow
Write-Host "emin olun. python.org/downloads adresinden" -ForegroundColor Yellow
Write-Host "Python 3.13 indirip kurabilirsiniz." -ForegroundColor Yellow
Write-Host ""
pause
}
}
#=======================================================
# ANA PROGRAM
#=======================================================
if ($AutoUpdate) {
if (-not (Test-PythonAvailable)) { Install-PythonWithPermission }
Invoke-UpdateAndLaunch
exit 0
}
# 1. Python kontrolu
if (-not (Test-PythonAvailable)) {
Install-PythonWithPermission
}
# 2. Kurulum tespit
if (Test-Path $ShortcutPath) {
# Daha once kurulmus — "Zaten Kurulu" menusu
Show-InstalledMenu
$key = Read-SingleKey
Write-Host ""
if ($key.Character -match '[kK]') {
Invoke-Uninstall
}
elseif ($key.Character -match '[qQ]') {
Write-Host ""
Write-Host "Cikis yapildi." -ForegroundColor DarkGray
exit 0
}
else {
# Enter veya baska tus → Guncelle ve Baslat
Invoke-UpdateAndLaunch
}
}
else {
# Ilk kullanim veya kurulum yapilmamis — Karsilama menusu
Show-Welcome
$key = Read-SingleKey
Write-Host ""
if ($key.Character -match '[kK]') {
Invoke-Install
}
elseif ($key.Character -match '[qQ]') {
Write-Host ""
Write-Host "Cikis yapildi. Tekrar bekleriz!" -ForegroundColor DarkGray
exit 0
}
else {
# Enter veya baska tus → Direkt Kullan
Invoke-DirectRun
}
}