fix: PC再起動時のGoogle Driveマウント切断・Read-only化対策および自動復旧機能の実装
This commit is contained in:
1 parent
6b78d6ee85
commit
6bc2d065e4
8 files changed
+283
-5
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# ==============================================================================
|
||||
# Setup Startup Task and Shortcut for MusicDownloader Auto-Mount
|
||||
# ==============================================================================
|
||||
|
||||
$scriptDir = "C:\VS2026\MusicDownloader"
|
||||
$vbsPath = Join-Path $scriptDir "run-auto-mount-silent.vbs"
|
||||
$ps1Path = Join-Path $scriptDir "auto-mount-gdrive.ps1"
|
||||
|
||||
# 1. Register to Startup Folder
|
||||
$startupFolder = [Environment]::GetFolderPath([Environment+SpecialFolder]::Startup)
|
||||
$startupVbs = Join-Path $startupFolder "MusicDownloader-AutoMount.vbs"
|
||||
Copy-Item -Path $vbsPath -Destination $startupVbs -Force
|
||||
Write-Host "[OK] Startup folder configured: $startupVbs"
|
||||
|
||||
# 2. Register to Windows Task Scheduler (At Logon)
|
||||
$taskName = "MusicDownloader-AutoMount"
|
||||
$action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$vbsPath`""
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 10)
|
||||
|
||||
try {
|
||||
# 既存タスクがあれば上書き登録
|
||||
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Description "Auto-mounts Google Drive (G:) to WSL2 and recovers MusicDownloader container on logon" | Out-Null
|
||||
Write-Host "[OK] Task Scheduler configured: $taskName"
|
||||
} catch {
|
||||
Write-Warning "[Warning] Failed to register ScheduledTask: $_"
|
||||
}
|
||||
|
||||
Write-Host "Setup completed successfully."
|
||||
Reference in new issue
Block a user