このブログでは、PowerShellスクリプトを活用して、Tera Termの自動インストールを実現する方法を紹介します。特に、クラウド環境での効率的なセットアップを目指す方や、Computeインスタンスの作成時にTera Termを自動的にインストールしたい方にとって、一助となれば幸いです。
動作確認済環境
OS: Windows Server 2022 Standard Edition (OCI VM)
Tera Term バージョン: 5.5.1
1. 手動で実行した場合
ステップ
- インストーラのダウンロード
- インストール開始(
/VERYSILENT) - インストーラの削除(オプション)
# Define the URL of the Tera Term installer
$Version = "5.5.1"
$InstallerFile = "teraterm-$Version-x64.exe"
$InstallerUrl = "https://github.com/TeraTermProject/teraterm/releases/download/v$Version/" + $InstallerFile
# Define the path where you want to save the installer
$InstallerPath = Join-Path $env:TEMP $InstallerFile
# Download the installer
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath
# Execute the installer silently
Start-Process -Wait -FilePath $InstallerPath -Args "/VERYSILENT"
# Clean up the installer after installation (optional)
Remove-Item $InstallerPath手動で実行した場合は、Tera Term のショートカットがデスクトップに自動的に作成されます。
2. OCI cloud-init で実行した場合
#ps1_sysnative
# Define the URL of the Tera Term installer
$Version = "5.5.1"
$InstallerFile = "teraterm-$Version-x64.exe"
$InstallerUrl = "https://github.com/TeraTermProject/teraterm/releases/download/v$Version/" + $InstallerFile
# Define the path where you want to save the installer
$InstallerPath = Join-Path $env:TEMP $InstallerFile
# Download the installer
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath
# Execute the installer silently
Start-Process -Wait -FilePath $InstallerPath -Args "/VERYSILENT"
# Create Shortcut (optional)
$Desktop = "$env:Public\Desktop"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Desktop\Tera Term 5.lnk")
$Shortcut.TargetPath = "C:\Program Files\teraterm5\ttermpro.exe"
$Shortcut.Save()
# Clean up the installer after installation (optional)
Remove-Item $InstallerPath- OCI cloud-init で実行した場合は、先頭に
#ps1_sysnativeを追加する必要があります。 - OCI cloud-init で実行した場合は、ショートカットが自動で作成されない現象が確認されています。そのため、ショートカットの作成をオプションとして追加します。
以上
ドキュメント
Tera Term ホームページ:日本語 英語
Tera Term ダウンロード