🌟

Windows Sandboxを有効にする (バッチファイル)

2021/07/06に公開

Windows 10 May 2019 Updateから提供されているWindows Sandboxを有効にするバッチファイルです。

@echo off
@echo on
chcp 65001 > nul
setlocal ENABLEDELAYEDEXPANSION

rem Require Administrator privileges
copy nul "%SystemRoot%\temp.tmp" 1>nul 2>&1
if errorlevel 1 (
	echo.
	echo Please run as administrator
	echo.
	timeout.exe /t 3
	exit /b 1
) else (
	del "%SystemRoot%\temp.tmp" 1>nul 2>&1
)

if "%1"=="Disable" (
	rem Disable Windows Sandbox
	set FEATURENAME_WINDOWSSANDBOX=Containers-DisposableClientVM
	dism.exe /Online /Disable-Feature /FeatureName:"!FEATURENAME_WINDOWSSANDBOX!"
) else (
	rem Enable Windows Sandbox
	set FEATURENAME_WINDOWSSANDBOX=Containers-DisposableClientVM
	dism.exe /Online /Enable-Feature /FeatureName:"!FEATURENAME_WINDOWSSANDBOX!" -All
)

endlocal
exit /b  0

Discussion