0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

bat 条件分岐して、install/uninstall と一部の文字だけ色を変更

Posted at

bat 条件分岐して、install/uninstall と一部の文字だけ色を変更

@echo off

set=[31m
set=[32m
set=[37m
set デフォルト=[0m

:INPUT_START
set exe_Path=C:\Users\test\Downloads\picture\
set f32bit=32bit
set f64bit=64bit

echo *****************************************
echo 1. %1%%ポリシー指定でインストール%デフォルト%
echo 2. %1%%Defaultポリシー指定でインストール%デフォルト%
echo 3. %1%%アンインストール%デフォルト%
echo *****************************************
set /p ui=1~3を選択してください: 

echo +-------------------------------------------------------+
echo  入力した文字は%%[%ui%]%デフォルト%でよろしいですか?
echo (Y / Necho +-------------------------------------------------------+
SET CONF_SELECT=
SET /P CONF_SELECT=
 
IF "%CONF_SELECT%"== SET CONF_SELECT=Y
IF /I NOT "%CONF_SELECT%"=="Y"  GOTO :INPUT_START

if "%PROCESSOR_ARCHITECTURE%" EQU "x86"   goto :WIN32
if "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" goto :WIN64
echo %%手動でインストールを行ってください。%デフォルト% & goto :FINISH

:WIN32
set f32bitPath=%exe_Path%%f32bit%
pushd %f32bitPath%

rem echo where /r %f32bitPath% /f *.exe
FOR /F %%i in ('where /r %f32bitPath% /f *.exe') DO @SET oput_exe=%%i

if exist %oput_exe% (
 Call :Main %oput_exe%
) else (
 echo "32bitのexeファイルは見つかりませんでした。"
)
rem 切断
popd
goto :FINISH

:WIN64
set f64bitPath=%exe_Path%%f64bit%
pushd %f64bitPath%

rem echo where /r %f64bitPath% /f *.exe
FOR /F %%i in ('where /r %f64bitPath% /f *.exe') DO @SET oput_exe=%%i
if exist %oput_exe% (
 Call :Main %oput_exe%
) else (
 echo "64bitのexeファイルは見つかりませんでした。"
)
rem 切断
popd

goto :FINISH

:FINISH

:Main
echo %oput_exe%
if %ui%==1 (
  rem ポリシー指定でインストール
  %oput_exe% /install /norestart ポリシー指定
) else if %ui%==2 (
  rem Defaultでインストール
  %oput_exe% /install /norestart
) else if %ui%==3 (
  rem アンインストール
  %oput_exe% /uninstall 
) else (
  echo %%1~3のどれかを選択してください。%デフォルト% 
)

pause
exit

設定できる色の一覧

@echo off
echo [30m[0m
echo [31m[0m
echo [32m[0m
echo [33m[0m
echo [34m[0m
echo [35mマゼンダ[0m
echo [36mシアン[0m
echo [37m[0m
echo [90m明るい黒[0m
echo [91m明るい赤[0m
echo [92m明るい緑[0m
echo [93m明るい黄[0m
echo [94m明るい青[0m
echo [95m明るいマゼンダ[0m
echo [96m明るいシアン[0m
echo [97m明るい白[0m
pause
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?