2013-04-23 200 views
1

如何在安裝框架時將此腳本移至INSTALLAX? 即使它已經存在,它也會安裝該框架。IF EXIST GOTO NEXT

我錯過了什麼?

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 
+1

您在64位標籤的IF子句中缺少ELSE。 – Vicky 2013-04-23 11:23:59

+0

是的,還有比ELSE更多的東西,比如「&」。 – ElektroStudios 2013-04-23 11:30:03

回答

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) 

(增加了可讀性換行只)

此外,你還缺少一個人。

+0

謝謝他的幫助! – user2310230 2013-04-26 12:05:28

2

你的問題是顯而易見的:

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

沒有ELSE在條件

而在替補「:INSTALLFRAMEWORK」和「:INSTALLAX」你不告訴退出程序,使「:INSTALLAX」總是處理。

另外在「:INSTALLAX」您使用的兩個命令,而無需使用連接操作符「&」程序(回聲布拉布拉>>文件轉到布拉布拉

下面是代碼:

@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