无需直接引用临时文件夹;假设当前工作目录:
@echo off
rem install.bat
mkdir %ProgramFiles%\HybRIDS
echo %ERRORLEVEL% created directory %ProgramFiles%\HybRIDS
copy * C:\"Program Files"\HybRIDS
echo %ERRORLEVEL% copied files
del C:\"Program Files"\HybRIDS\install.bat
echo %ERRORLEVEL% success?
配置 sed 进行测试时,请确保最大化安装ShowInstallProgramWindow=3
并正确设置安装脚本AppLaunched=cmd /c install.bat
。还要pause
在批处理脚本的末尾添加语句,例如BambiLongGone建议进行测试。我使用以下格式进行错误处理(假设安装窗口是隐藏的ShowInstallProgramWindow=1
)
@echo off
REM install.bat
mkdir %ProgramFiles%\HybRIDS
REM mkdir may fail because the folder already exists - ignore errors.
move * %ProgramFiles%\HybRIDS > temp.txt 2>&1
set i=%ERRORLEVEL%
REM check for errors!
if not %i%==0 (
REM inform the user with a prompt (will not wait for it to close though...)
start cmd /c^
echo error occured during installation^
& type temp.txt^
& echo what to do next...^
& pause
)
REM don't keep the install and temp.txt file
del %ProgramFiles%\install.bat
del %ProgramFiles%\temp.txt
如果您有任何问题,请告诉我。