LoginSignup
1
0

Portable modeのVScodeも自動アップデートしたい

Last updated at Posted at 2023-09-21

ポータブルモードのVScodeは自動アップデートしてくれない

困った。
検索するとパワーシェルスクリプトが出てきた。
こいつを遣えればいいんだけど、素直に動いてくれないのでガイド作成。

コード

https://github.com/microsoft/vscode/issues/56326
ここにあるようなものをWindows環境のPowershellで動くようにしたもの。

vscode_update.ps1
# Remove temp file from portable user data
Remove-Item -Recurse -Force -Path $PSScriptRoot"/data/user-data" -Include @("Backups", "Cache", "CachedData", "GPUCache", "logs")

# Download latest stable build
curl.exe -L "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-archive" -o $PSScriptRoot"/stable.zip"

# 危険なのでコメントアウト。必要なければそのままで。
# Delete anything except user data, update script and downloaded zip file
# Get-ChildItem -Path $PSScriptRoot -Exclude @("data", "_LocalHistorys", "livereloadready-workspace.code-workspace", "vscode_update.ps1", "vscode_update202309", "stable.zip") | Remove-Item -Recurse -Force -Path $PSScriptRoot

# Unzip it
Expand-Archive -Path $PSScriptRoot"/stable.zip" -DestinationPath $PSScriptRoot -Force

# Delete downloaded package
Remove-Item -Path $PSScriptRoot"/stable.zip"

Pause

「vscode_update.ps1」というファイル名でVScode本体のフォルダに配置すること。

運用方法

Powershellは色々セキュリティ面で面倒っぽい。素直にダブルクリックで動いてくれない。
なので、Windowsのショートカットファイルを作成して、そいつをワンクリックでアプデを行う運用を目指す。

ショートカット名:
vscode_update202309
リンク先:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File "C:\@work\Program Files\VSCode\vscode_update.ps1"

リンク先は各自直してね。

image.png

実行結果

image.png

とりあえず、VScodeを使っていて「アプデがあります」と出たらショートカットをクリックすることでの運用でいけそうだ。
少しだけ楽になった。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0