Roblox Studioのアップデートでショートカットが壊れる問題をCMDで回避する
Roblox StudioをWindowsで使っていると、バージョンアップ後にデスクトップのショートカットが使えなくなることがあります。
原因は、Roblox Studioの実行ファイルが次のようなバージョンごとのディレクトリに置かれているためです。
%LOCALAPPDATA%\Roblox\Versions\version-xxxxxxxxxxxxxxxx\RobloxStudioBeta.exe
アップデートによって version-xxxxxxxxxxxxxxxx の部分が変わると、古い実行ファイルを直接参照しているショートカットは無効になってしまいます。
そこで、固定されたCMDファイルを1つ用意して、起動するたびに最新のRoblox Studioを探すようにします。
RobloxStudio.cmdを作成する
まず、次のディレクトリを作成します。
C:\Tools
そこに、以下の内容を C:\Tools\RobloxStudio.cmd として保存します。
@echo off
setlocal EnableExtensions
set "ROBLOX_VERSIONS=%LOCALAPPDATA%\Roblox\Versions"
set "STUDIO="
if not exist "%ROBLOX_VERSIONS%\" (
echo [ERROR] Roblox Versions folder was not found:
echo %ROBLOX_VERSIONS%
pause
exit /b 1
)
rem 新しいバージョンディレクトリから順番に調べる
for /f "delims=" %%D in ('dir /b /ad /o-d "%ROBLOX_VERSIONS%\*" 2^>nul') do (
if exist "%ROBLOX_VERSIONS%\%%D\RobloxStudioBeta.exe" (
set "STUDIO=%ROBLOX_VERSIONS%\%%D\RobloxStudioBeta.exe"
goto :studio_found
)
)
echo [ERROR] RobloxStudioBeta.exe was not found.
pause
exit /b 1
:studio_found
echo Roblox Studio:
echo "%STUDIO%"
start "" "%STUDIO%"
endlocal
exit /b 0
C:\Tools\RobloxStudio.cmd を実行すれば、その時点でインストールされているRoblox Studioのうち、更新日時が最も新しいバージョンを起動できます。
デスクトップにショートカットを作る
次に、デスクトップの何もない場所を右クリックし、「新規作成」から「ショートカット」を選択します。
「項目の場所を入力してください」には、次の内容を入力します。
C:\Windows\System32\cmd.exe /d /c C:\Tools\RobloxStudio.cmd
ショートカットを作成したら、プロパティを開いて「作業フォルダー」を次のように設定します。
C:\Tools
これで、デスクトップのショートカットはRoblox Studio本体ではなく、C:\Tools\RobloxStudio.cmd を経由して起動するようになります。
仕組み
起動の流れは単純です。
デスクトップのショートカット
↓
C:\Tools\RobloxStudio.cmd
↓
%LOCALAPPDATA%\Roblox\Versions を検索
↓
更新日時が最も新しい RobloxStudioBeta.exe を発見
↓
Roblox Studioを起動
例えばアップデートによって、
version-111111111111
から
version-222222222222
へ変わっても、CMD側で起動するたびに検索するため、ショートカットを作り直す必要がありません。
ショートカット作成まで自動化する版
ショートカットの作成もCMD側で自動化するなら、次のようにできます。
@echo off
setlocal EnableExtensions
set "ROBLOX_VERSIONS=%LOCALAPPDATA%\Roblox\Versions"
set "STUDIO="
if not exist "%ROBLOX_VERSIONS%\" (
echo [ERROR] Roblox Versions folder was not found:
echo %ROBLOX_VERSIONS%
pause
exit /b 1
)
for /f "delims=" %%D in ('dir /b /ad /o-d "%ROBLOX_VERSIONS%\*" 2^>nul') do (
if exist "%ROBLOX_VERSIONS%\%%D\RobloxStudioBeta.exe" (
set "STUDIO=%ROBLOX_VERSIONS%\%%D\RobloxStudioBeta.exe"
goto :studio_found
)
)
echo [ERROR] RobloxStudioBeta.exe was not found.
pause
exit /b 1
:studio_found
set "SHORTCUT_ICON=%STUDIO%,0"
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ^
"$desktop=[Environment]::GetFolderPath('Desktop');" ^
"$lnk=Join-Path $desktop 'Roblox Studio.lnk';" ^
"$ws=New-Object -ComObject WScript.Shell;" ^
"$s=$ws.CreateShortcut($lnk);" ^
"$s.TargetPath=$env:ComSpec;" ^
"$s.Arguments='/d /c C:\Tools\RobloxStudio.cmd';" ^
"$s.WorkingDirectory='C:\Tools';" ^
"$s.IconLocation=$env:SHORTCUT_ICON;" ^
"$s.Description='Launch the newest installed Roblox Studio';" ^
"$s.WindowStyle=7;" ^
"$s.Save();"
start "" "%STUDIO%"
endlocal
exit /b 0
この内容を C:\Tools\RobloxStudio.cmd として保存して実行すると、デスクトップに「Roblox Studio」というショートカットが作成され、Roblox Studioが起動します。同じCMDを再び実行した場合は、ショートカットが同じ内容で更新されます。
以後は、そのショートカットから起動するだけです。
まとめ
Roblox Studioの実行ファイルを直接ショートカットに登録するのではなく、次のように固定されたCMDを1段階挟みます。
固定CMD
↓
最新バージョンを検索
↓
RobloxStudioBeta.exe
これで、アップデートによる実行ファイルのパス変更を気にする必要がなくなります。WindowsでRoblox Studioを頻繁に使う場合に便利な方法です。