需要有关批处理变量和子字符串的帮助

时间:2017-04-02 19:09:20

标签: batch-file

我有%arch的问题:~1,3%正确显示 回显%arch:~1,3%输出x64就像它应该的那样 但是当它被用作一个变量时,它会把一切搞得一团糟

@echo off
setlocal enabledelayedexpansion
Color 0A
cls
title PORTABLE LASTPASS LAUNCHER

:ARCHCHECK
cls
set arch=
if exist "%PROGRAMFILES(X86)%" set "arch=_x64" & goto LASTPASSCHECK

:LASTPASSCHECK
cls
if not exist .\bin\lastpass\lastapp%arch%.exe goto FILECHECK
if not exist .\bin\lastpass\lastapphook%arch%.dll goto FILECHECK
goto WGETUPDATE

:FILECHECK
cls
if not exist .\extra\lastappinstall%arch%.exe goto DOWNLOADLASTPASS
if not exist .\bin\7-ZipPortable\7-ZipPortable.exe goto 7ZIPINSTALLERCHECK
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapp%arch%.exe -o.\bin\lastpass\
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapphook%arch%.dll -o.\bin\lastpass\
goto LASTPASSCHECK

:DOWNLOADLASTPASS
cls
if exist lastappinstall%arch%.exe goto MOVELASTPASS
if not exist .\bin\wget.exe call :DOWNLOADWGET
.\bin\wget.exe https://lastpass.com/download/cdn/lastappinstall%arch%.exe

:MOVELASTPASS
cls
move lastappinstall%arch%.exe .\extra\lastappinstall%arch%.exe
goto FILECHECK

当我用作变量时得到的输出是它认为它以某种方式说“ziparcharcharch”:/

1 个答案:

答案 0 :(得分:0)

自己解决了 而不是%arch:~1,3%我应该把%arch:~2,2%,因为我想要两个跳到字符并打印下一个2 即,而不是_x64变成x64,它变成64