本帖最后由 xwlzx 于 2012-4-10 08:25 编辑
回复 16# 半芯竹
本来想用AU3写个配置脚本的,但是想想很久没用批命令行了,所以就写了一个批处理配置文件,但是批处理读取注册表中AU3安装路径时其后面多了一个空格导致不能正确自动配置AU3路径,运行时需手工设置。否则测试会提示上述错误。修正后的批处理文件代码如下:@echo off
color 0a
if "%~1"=="" start /min "" "%~0" h & exit
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt" /v "InstallDir"
if ERRORLEVEL 1 goto errtx
For /f "skip=3 delims=" %%i IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt" /v InstallDir') do set lsbl=%%i
For /f "tokens=3* delims= " %%j IN ('echo %lsbl%') do set ljml=%%j %%k
if "%ljml:~-1%"==" " set ljml=%ljml:~0,-1%
if "%ljml:~-1%"==" " set ljml=%ljml:~0,-1%
if "%ljml:~-1%"==" " set ljml=%ljml:~0,-1%
echo [config]>"%cd%\AutoItIDE\Data\config.ini"
if exist "%cd%\AutoItIDE\Data\Language\zh-CN.lng" (
echo language=zh-CN.lng>>"%cd%\AutoItIDE\Data\config.ini"
)else (
echo language=english.lng>>"%cd%\AutoItIDE\Data\config.ini"
)
echo autoitexe=%ljml%\AutoIt3.exe>>"%cd%\AutoItIDE\Data\config.ini"
echo helpfileexe=%ljml%\AutoIt3Help.exe>>"%cd%\AutoItIDE\Data\config.ini"
echo autoit2exe=%ljml%\Aut2Exe\Aut2exe.exe>>"%cd%\AutoItIDE\Data\config.ini"
::================================================================================
echo On Error Resume Next>"%TEMP%\createcs.vbs"
echo attrib +H "%TEMP%\createcs.vbs"
echo Set Shell=CreateObject("WScript.Shell")>>"%TEMP%\createcs.vbs"
echo CsPath=Shell.SpecialFolders("Desktop")>>"%TEMP%\createcs.vbs"
echo Set link=Shell.CreateShortcut(CsPath ^& "\\AutoItIDE.lnk")>>"%TEMP%\createcs.vbs"
echo link.description="位置:"^& "%CD%\AutoItIDE">>"%TEMP%\createcs.vbs"
echo link.TargetPath="%CD%\AutoItIDE\Autoit_Studio.exe">>"%TEMP%\createcs.vbs"
echo link.WindowStyle=1 >>"%TEMP%\createcs.vbs"
echo link.WorkingDirectory="%CD%\AutoItIDE">>"%TEMP%\createcs.vbs"
echo link.Save>>"%TEMP%\createcs.vbs"
"%TEMP%\createcs.vbs"
del /a /f "%TEMP%\createcs.vbs"
::===============================================================================
echo Set fso = CreateObject("Scripting.FileSystemObject") >"%TEMP%"\createcs.vbs
echo createobject("wscript.shell").popup"【已完成基本配置并创建快捷方式】",5,"龙在线提示:完成",64+4096 >>"%TEMP%"\createcs.vbs
echo fso.DeleteFile(WScript.ScriptName) >>"%TEMP%"\createcs.vbs
start /d "%TEMP%" createcs.vbs
goto cgexit
:errtx
echo Set fso = CreateObject("Scripting.FileSystemObject") >"%TEMP%"\createcs.vbs
echo createobject("wscript.shell").popup"【请您先安装AutoIt再运行我】",5,"龙在线提示:没有安装AU3",64+4096 >>"%TEMP%"\createcs.vbs
echo fso.DeleteFile(WScript.ScriptName) >>"%TEMP%"\createcs.vbs
start /d "%TEMP%" createcs.vbs
:cgexit
exit
|