-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
30 lines (24 loc) · 1008 Bytes
/
Copy pathrun.ps1
File metadata and controls
30 lines (24 loc) · 1008 Bytes
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
# PDF 發票證明聯處理器啟動腳本 (PowerShell)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "PDF 發票證明聯處理器" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 檢查虛擬環境是否存在
if (-not (Test-Path "venv\Scripts\python.exe")) {
Write-Host "[錯誤] 虛擬環境不存在,請先執行初始化" -ForegroundColor Red
Write-Host "執行: python -m venv venv" -ForegroundColor Yellow
Read-Host "按 Enter 鍵退出"
exit 1
}
# 設置編碼以避免 emoji 顯示問題
$env:PYTHONIOENCODING = "utf-8"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# 激活虛擬環境並執行主程式
& "venv\Scripts\Activate.ps1"
python main.py
# 如果發生錯誤,暫停以便查看訊息
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "[錯誤] 程式執行時發生錯誤" -ForegroundColor Red
Read-Host "按 Enter 鍵退出"
}