Batch file 批量安装位置变换器
我搞不懂这个,我真的不知道该如何表述这个问题,我希望这足够好 我正在做这个实验。 当我故意插入一个无效目录时,我收到消息“系统找不到指定的路径”Batch file 批量安装位置变换器,batch-file,Batch File,我搞不懂这个,我真的不知道该如何表述这个问题,我希望这足够好 我正在做这个实验。 当我故意插入一个无效目录时,我收到消息“系统找不到指定的路径” @echo off set /a test=0 title Color changer if exist "Settings/files.bat" ( call Settings/files.bat ) else ( mkdir Settings echo set savloc=%cd%>Settings\files.bat call Setti
@echo off
set /a test=0
title Color changer
if exist "Settings/files.bat" (
call Settings/files.bat
) else (
mkdir Settings
echo set savloc=%cd%>Settings\files.bat
call Settings\files.bat
)
if exist "%savloc%\color.bat" (
call "%savloc%\color.bat"
) else (
color 0f
)
set menu=2
goto menu
:menu
cls
echo color : change color
echo cd : change direction
set /p menu=
if "%menu%" == "color" goto setcolor
if "%menu%" == "cd" goto changedir
else goto menu
:changedir
cls
set test=0
echo (current location: %savloc%)
echo What do you want your new location to be?
set /p dir=#
echo set test=1 > "%dir%\testfile.bat"
call "%dir%\testfile.bat"
If EXIST "%dir%\testfile.bat" (
echo Valid Location! (current location: %dir%)
pause >nul
echo set savloc=%dir%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
iF NOT EXIST "%dir%\testfile.bat" (
echo Invalid Location, Please redo This step. (reset location to: %cd%)
pause >nul
echo set savloc=%cd%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
goto menu
:setcolor
cls
echo What do you want the color to be?
echo.
set /p clr=#
color %clr%
echo color %clr%>"%savloc%\color.bat"
goto menu
我尝试使用“test”变量,将其保存到该目录中,然后读取,而不是:
If EXIST "%dir%\testfile.bat" (
及
但这也不起作用
我真的希望有人能帮助我
更新:
现在我将声明更改为:
if exist "%dir%" (
echo Valid Location! (current location: %dir%)
pause >nul
echo set savloc=%dir%> Settings\files.bat
call Settings\files.bat
goto menu
) else (
echo Invalid Location, Please redo This step. (reset location to: %cd%)
pause >nul
echo set savloc=%cd%> Settings\files.bat
call Settings\files.bat
goto menu
)
goto menu
但现在,当目录无效时,它只是将其回显到settings\files.bat中
它什么也没说。在测试目录之前,您正在回显到
%dir%\testfile.bat
@echo off
set /a test=0
title Color changer
if exist "Settings/files.bat" (
call Settings/files.bat
) else (
mkdir Settings
echo set savloc=%cd%>Settings\files.bat
call Settings\files.bat
)
if exist "%savloc%\color.bat" (
call "%savloc%\color.bat"
) else (
color 0f
)
set menu=2
goto menu
:menu
cls
echo color : change color
echo cd : change direction
set /p menu=
if "%menu%" == "color" goto setcolor
if "%menu%" == "cd" goto changedir
else goto menu
:changedir
cls
set test=0
echo (current location: %savloc%)
echo What do you want your new location to be?
set /p dir=#
echo set test=1 > "%dir%\testfile.bat"
call "%dir%\testfile.bat"
If EXIST "%dir%\testfile.bat" (
echo Valid Location! (current location: %dir%)
pause >nul
echo set savloc=%dir%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
iF NOT EXIST "%dir%\testfile.bat" (
echo Invalid Location, Please redo This step. (reset location to: %cd%)
pause >nul
echo set savloc=%cd%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
goto menu
:setcolor
cls
echo What do you want the color to be?
echo.
set /p clr=#
color %clr%
echo color %clr%>"%savloc%\color.bat"
goto menu
当目录无效时,重定向无法工作,您将收到错误消息
首先检查目录是否存在。修复示例:
set /p dir=#
If NOT EXIST "%dir% ( echo "%dir% does not exist
goto menu
)
rem now echo has a chance to work
echo set test=1> "%dir%\testfile.bat"
call "%dir%\testfile.bat"
在测试目录之前,您正在回显到
%dir%\testfile.bat
@echo off
set /a test=0
title Color changer
if exist "Settings/files.bat" (
call Settings/files.bat
) else (
mkdir Settings
echo set savloc=%cd%>Settings\files.bat
call Settings\files.bat
)
if exist "%savloc%\color.bat" (
call "%savloc%\color.bat"
) else (
color 0f
)
set menu=2
goto menu
:menu
cls
echo color : change color
echo cd : change direction
set /p menu=
if "%menu%" == "color" goto setcolor
if "%menu%" == "cd" goto changedir
else goto menu
:changedir
cls
set test=0
echo (current location: %savloc%)
echo What do you want your new location to be?
set /p dir=#
echo set test=1 > "%dir%\testfile.bat"
call "%dir%\testfile.bat"
If EXIST "%dir%\testfile.bat" (
echo Valid Location! (current location: %dir%)
pause >nul
echo set savloc=%dir%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
iF NOT EXIST "%dir%\testfile.bat" (
echo Invalid Location, Please redo This step. (reset location to: %cd%)
pause >nul
echo set savloc=%cd%> Settings\files.bat
call Settings\files.bat
del "%dir%\testfile.bat"
goto menu
)
goto menu
:setcolor
cls
echo What do you want the color to be?
echo.
set /p clr=#
color %clr%
echo color %clr%>"%savloc%\color.bat"
goto menu
当目录无效时,重定向无法工作,您将收到错误消息
首先检查目录是否存在。修复示例:
set /p dir=#
If NOT EXIST "%dir% ( echo "%dir% does not exist
goto menu
)
rem now echo has a chance to work
echo set test=1> "%dir%\testfile.bat"
call "%dir%\testfile.bat"
我这样做了,但仍然没有真正起作用,我更新了问题。我希望你能帮忙。谢谢你这么快就回复了。我这么做了,但还是不起作用,我更新了问题。我希望你能帮忙。谢谢你这么快就回复了。