如果存在GOTO NEXT

时间:2013-04-23 11:07:47

标签: batch-file

如果已安装Framework,如何让此脚本转到INSTALLAX? 即使它已经存在,它也会安装框架。

我错过了什么?

Echo off
IF EXIST "%Programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit)

:32-Bit
IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX ELSE GOTO INSTALLFRAMEWORK

:64-Bit
IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX ELSE GOTO INSTALLFRAMEWORK

:INSTALLFRAMEWORK
start "" /w "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Prerequisites\Net Framework 4.0\dotNetFx40_Full_x86_x64.exe" /q /norestart
ECHO .NETFramework4.0Installed %Date% %TIME% >> \\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\Framework\%COMPUTERNAME%.log

:INSTALLAX
start "" /w "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\DynamicsAX\setup.exe" RunMode=Custom HideUI=1 AcceptLicenseTerms=1 ByPasswarnings=0 InstallClientUI=1 ClientAOSServer=ax-aos02-prod AOSPort=2712 AOSWsdlPort=8101 ClientLanguage=en-us ConfigurePrerequisites=1 ClientConfigFile="\\sespfs01\appdata01\Deployment\MicrosoftDynamicsAX\AX_Icons\DAX_Prod(usr)32-bit.axc" LogDir="\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log"
ECHO AXDynamics2012Installed %Date% %TIME% >> \\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\AXDynamics\%COMPUTERNAME%.log" GOTO END

:END
Exit

2 个答案:

答案 0 :(得分:2)

你的问题很明显:

IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX GOTO INSTALLFRAMEWORK
条件中

没有 ELSE

在潜艇“: INSTALLFRAMEWORK ”和“: INSTALLAX ”中,您没有告诉要退出程序,所以“: INSTALLAX ”总是被处理。

同样在“: INSTALLAX ”过程中,您使用两个命令而不使用连接运算符“& ”( Echo blabla>>文件goto blabla

以下是代码:

@Echo off

Set "FW32=%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe"
Set "FW64=%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe"

IF EXIST "%Programfiles(x86)%" (
    REM 64BIT
    IF EXIST "%FW64%" (GOTO :INSTALLAX) ELSE (GOTO :INSTALLFRAMEWORK)
) ELSE (
    REM 32BIT
    IF EXIST "%FW32%" (GOTO :INSTALLAX) ELSE (GOTO :INSTALLFRAMEWORK)
)

:INSTALLFRAMEWORK
start "" /Wait "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Prerequisites\Net Framework 4.0\dotNetFx40_Full_x86_x64.exe" /q /norestart
ECHO .NETFramework4.0Installed %Date% %TIME% >> "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\Framework\%COMPUTERNAME%.log"
Pause&Exit

:INSTALLAX
start "" /Wait "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\DynamicsAX\setup.exe" RunMode=Custom HideUI=1 AcceptLicenseTerms=1 ByPasswarnings=0 InstallClientUI=1 ClientAOSServer=ax-aos02-prod AOSPort=2712 AOSWsdlPort=8101 ClientLanguage=en-us ConfigurePrerequisites=1 ClientConfigFile="\\sespfs01\appdata01\Deployment\MicrosoftDynamicsAX\AX_Icons\DAX_Prod(usr)32-bit.axc" LogDir="\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log"
ECHO AXDynamics2012Installed %Date% %TIME% >> "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\AXDynamics\%COMPUTERNAME%.log"
Pause&Exit

答案 1 :(得分:0)

你已经在第一个IF语句中做了正确的(使用括号)。

:32-Bit
IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe"
  (GOTO INSTALLAX) ELSE (GOTO INSTALLFRAMEWORK)

:64-Bit
IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe"
  (GOTO INSTALLAX) ELSE (GOTO INSTALLFRAMEWORK)

(仅为可读性添加换行符)

另外,你错过了一个ELSE。